From c69efa5efce6d9a820f8902ca62305cddea163e6 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Wed, 7 Sep 2011 14:51:40 -0400 Subject: [PATCH] Remove frameworks' reference to an obsolete Bouncycastle keystore file. Without this, some SSL code fails with an exception: java.io.FileNotFoundException: /system/etc/security/cacerts.bks: open failed: ENOENT (No such file or directory) at libcore.io.IoBridge.open(IoBridge.java:410) at java.io.FileInputStream.(FileInputStream.java:78) at java.io.FileInputStream.(FileInputStream.java:105) at org.apache.harmony.xnet.provider.jsse.DefaultSSLContextImpl.getTrustManagers(DefaultSSLContextImpl.java:115) at org.apache.harmony.xnet.provider.jsse.SSLContextImpl.(SSLContextImpl.java:71) at org.apache.harmony.xnet.provider.jsse.OpenSSLContextImpl.(OpenSSLContextImpl.java:34) at org.apache.harmony.xnet.provider.jsse.DefaultSSLContextImpl.(DefaultSSLContextImpl.java:59) at java.lang.Class.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1319) at java.security.Provider.newInstance(Provider.java:989) ... 15 more Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory) at libcore.io.Posix.open(Native Method) at libcore.io.BlockGuardOs.open(BlockGuardOs.java:98) at libcore.io.IoBridge.open(IoBridge.java:393) ... 24 more Change-Id: I91de30746c1355ff9e0c2a9479392a50fe45aa23 --- .../test/InstrumentationCoreTestRunner.java | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/test-runner/src/android/test/InstrumentationCoreTestRunner.java b/test-runner/src/android/test/InstrumentationCoreTestRunner.java index ff99a74930fa2..036a2275455c3 100644 --- a/test-runner/src/android/test/InstrumentationCoreTestRunner.java +++ b/test-runner/src/android/test/InstrumentationCoreTestRunner.java @@ -51,35 +51,33 @@ public class InstrumentationCoreTestRunner extends InstrumentationTestRunner { /** * Convenience definition of our log tag. - */ + */ private static final String TAG = "InstrumentationCoreTestRunner"; - + /** * True if (and only if) we are running in single-test mode (as opposed to * batch mode). */ private boolean singleTest = false; - + @Override public void onCreate(Bundle arguments) { // We might want to move this to /sdcard, if is is mounted/writable. File cacheDir = getTargetContext().getCacheDir(); - // Set some properties that the core tests absolutely need. + // Set some properties that the core tests absolutely need. System.setProperty("user.language", "en"); System.setProperty("user.region", "US"); - + System.setProperty("java.home", cacheDir.getAbsolutePath()); System.setProperty("user.home", cacheDir.getAbsolutePath()); System.setProperty("java.io.tmpdir", cacheDir.getAbsolutePath()); - System.setProperty("javax.net.ssl.trustStore", - "/etc/security/cacerts.bks"); - + if (arguments != null) { String classArg = arguments.getString(ARGUMENT_TEST_CLASS); - singleTest = classArg != null && classArg.contains("#"); + singleTest = classArg != null && classArg.contains("#"); } - + super.onCreate(arguments); } @@ -89,36 +87,36 @@ public class InstrumentationCoreTestRunner extends InstrumentationTestRunner { runner.addTestListener(new TestListener() { /** - * The last test class we executed code from. + * The last test class we executed code from. */ private Class lastClass; - + /** * The minimum time we expect a test to take. */ private static final int MINIMUM_TIME = 100; - + /** * The start time of our current test in System.currentTimeMillis(). */ private long startTime; - + public void startTest(Test test) { if (test.getClass() != lastClass) { lastClass = test.getClass(); printMemory(test.getClass()); } - + Thread.currentThread().setContextClassLoader( test.getClass().getClassLoader()); - + startTime = System.currentTimeMillis(); } - + public void endTest(Test test) { if (test instanceof TestCase) { cleanup((TestCase)test); - + /* * Make sure all tests take at least MINIMUM_TIME to * complete. If they don't, we wait a bit. The Cupcake @@ -126,7 +124,7 @@ public class InstrumentationCoreTestRunner extends InstrumentationTestRunner { * short time, which causes headache for the CTS. */ long timeTaken = System.currentTimeMillis() - startTime; - + if (timeTaken < MINIMUM_TIME) { try { Thread.sleep(MINIMUM_TIME - timeTaken); @@ -136,15 +134,15 @@ public class InstrumentationCoreTestRunner extends InstrumentationTestRunner { } } } - + public void addError(Test test, Throwable t) { // This space intentionally left blank. } - + public void addFailure(Test test, AssertionFailedError t) { // This space intentionally left blank. } - + /** * Dumps some memory info. */ @@ -154,7 +152,7 @@ public class InstrumentationCoreTestRunner extends InstrumentationTestRunner { long total = runtime.totalMemory(); long free = runtime.freeMemory(); long used = total - free; - + Log.d(TAG, "Total memory : " + total); Log.d(TAG, "Used memory : " + used); Log.d(TAG, "Free memory : " + free); @@ -170,7 +168,7 @@ public class InstrumentationCoreTestRunner extends InstrumentationTestRunner { */ private void cleanup(TestCase test) { Class clazz = test.getClass(); - + while (clazz != TestCase.class) { Field[] fields = clazz.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { @@ -185,15 +183,15 @@ public class InstrumentationCoreTestRunner extends InstrumentationTestRunner { } } } - + clazz = clazz.getSuperclass(); } } - + }); - + return runner; - } + } @Override List> getBuilderRequirements() {