diff options
author | 2016-10-13 15:14:45 -0700 | |
---|---|---|
committer | 2016-10-13 17:38:52 -0700 | |
commit | a34efacf93ecb3313abb74df7033c74f3129cf93 (patch) | |
tree | 53ed260936128c1517d40ebdd7b23d279c2bdbad | |
parent | 834a448aa91a44c9076d3f7dc92b45f550d96285 (diff) |
Test for the CC RegionSpace::WalkInternal crash.
Bug: 31712511
Bug: 12687968
Test: test-art-host with CC.
Change-Id: I5443ae24d76f710c7820530e91f47cacea126ff9
-rw-r--r-- | test/130-hprof/src/Main.java | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/test/130-hprof/src/Main.java b/test/130-hprof/src/Main.java index 57be3a7d2f..c04bb86313 100644 --- a/test/130-hprof/src/Main.java +++ b/test/130-hprof/src/Main.java @@ -87,6 +87,12 @@ public class Main { } public static void main(String[] args) throws Exception { + testBasicDump(); + testAllocationTrackingAndClassUnloading(); + testGcAndDump(); + } + + private static void testBasicDump() throws Exception { // Create some data. Object data[] = new Object[TEST_LENGTH]; for (int i = 0; i < data.length; i++) { @@ -103,8 +109,10 @@ public class Main { } } System.out.println("Generated data."); - createDumpAndConv(); + } + + private static void testAllocationTrackingAndClassUnloading() throws Exception { Class<?> klass = Class.forName("org.apache.harmony.dalvik.ddmc.DdmVmInternal"); if (klass == null) { throw new AssertionError("Couldn't find path class loader class"); @@ -123,6 +131,57 @@ public class Main { enableMethod.invoke(null, false); } + private static void testGcAndDump() throws Exception { + Allocator allocator = new Allocator(); + Dumper dumper = new Dumper(allocator); + allocator.start(); + dumper.start(); + try { + allocator.join(); + dumper.join(); + } catch (InterruptedException e) { + System.err.println("join interrupted"); + } + } + + private static class Allocator extends Thread { + private static int ARRAY_SIZE = 1024; + public volatile boolean running = true; + public void run() { + Object[] array = new Object[ARRAY_SIZE]; + int i = 0; + while (running) { + array[i] = new byte[1024]; + if (i % ARRAY_SIZE == 0) { + Main.sleep(100L); + } + i = (i + 1) % ARRAY_SIZE; + } + } + } + + private static class Dumper extends Thread { + Dumper(Allocator allocator) { + this.allocator = allocator; + } + Allocator allocator; + public void run() { + for (int i = 0; i < 10; ++i) { + Main.sleep(1000L); + createDumpAndConv(); + } + allocator.running = false; + } + } + + public static void sleep(long ms) { + try { + Thread.sleep(ms); + } catch (InterruptedException e) { + System.err.println("sleep interrupted"); + } + } + private static File getHprofConf() { // Use the java.library.path. It points to the lib directory. File libDir = new File(System.getProperty("java.library.path").split(":")[0]); |