summaryrefslogtreecommitdiff
path: root/tools/preload-check/src
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2019-04-16 14:49:42 -0700
committerAndreas Gampe <agampe@google.com>2019-04-16 14:52:14 -0700
commitbb621f2df4740f43c31c62916f33085f54036f0e (patch)
treec3eee02945be325346f65bbbaeeff2ebbde6bd80 /tools/preload-check/src
parentbc17e4b328a4ce1146c7b23798c7aa7f03ee0c6d (diff)
PreloadCheck: Add support for regex checking
Add some reflection hackery to retrieve boot classpath dex files. This requires unstripped jars. Then use DexFile APIs to retrieve all classes, and run a check if the given regular exception matches. Use the new infrastructure to check that NoPreloadHolder classes are not initialized. Test: atest --test-mapping frameworks/base/tools/preload-check Change-Id: Ic19e950647e5827d3c3ec4a7109553f39be7f43a
Diffstat (limited to 'tools/preload-check/src')
-rw-r--r--tools/preload-check/src/com/android/preload/check/PreloadCheck.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/preload-check/src/com/android/preload/check/PreloadCheck.java b/tools/preload-check/src/com/android/preload/check/PreloadCheck.java
index 1fde40252939..00fd414e3ee2 100644
--- a/tools/preload-check/src/com/android/preload/check/PreloadCheck.java
+++ b/tools/preload-check/src/com/android/preload/check/PreloadCheck.java
@@ -16,7 +16,7 @@
package com.android.preload.check;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
@@ -97,6 +97,14 @@ public class PreloadCheck implements IDeviceTest {
}
}
+ /**
+ * Test the classes ending in NoPreloadHolder are not initialized.
+ */
+ @Test
+ public void testNoPreloadHolder() throws Exception {
+ run("com.android.preload.check.NotInitializedRegex", ".*NoPreloadHolder$", "true");
+ }
+
private void run(String cmd, String... args) throws Exception {
StringBuilder sb = new StringBuilder();
sb.append("app_process ")
@@ -107,7 +115,7 @@ public class PreloadCheck implements IDeviceTest {
sb.append(' ').append(escape(arg));
}
String res = mTestDevice.executeShellCommand(sb.toString());
- assertEquals(sb.toString(), "OK", res.trim());
+ assertTrue(sb.toString() + "\n===\n" + res, res.trim().endsWith("OK"));
}
private static String escape(String input) {