summaryrefslogtreecommitdiffstats
path: root/tests/CoreTests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/CoreTests')
-rw-r--r--tests/CoreTests/android/core/HeapTest.java90
1 files changed, 0 insertions, 90 deletions
diff --git a/tests/CoreTests/android/core/HeapTest.java b/tests/CoreTests/android/core/HeapTest.java
index 6116f5e..98cb28a 100644
--- a/tests/CoreTests/android/core/HeapTest.java
+++ b/tests/CoreTests/android/core/HeapTest.java
@@ -540,94 +540,4 @@ public class HeapTest extends TestCase {
objSize = (objSize * 4) / 5;
}
}
-
- // TODO: flaky test
- //@SmallTest
- public void testExternalOomeLarge() {
- /* Just shy of the typical max heap size so that it will actually
- * try to allocate it instead of short-circuiting.
- */
- final int HUGE_SIZE = (16 * 1024 * 1024 - 32);
-
- assertFalse(VMRuntime.getRuntime().trackExternalAllocation(HUGE_SIZE));
- }
-
- /**
- * "Allocates" external memory in progressively smaller chunks until there's
- * only roughly 16 bytes left.
- *
- * @return the number of bytes allocated
- */
- private long allocateMaxExternal() {
- final VMRuntime runtime = VMRuntime.getRuntime();
- final int SIXTEEN_MB = (16 * 1024 * 1024);
- final int MIN_SIZE = 16;
- long totalAllocated = 0;
- boolean success;
-
- success = false;
- try {
- /* "Allocate" progressively smaller chunks to "fill up" the entire heap.
- */
- int objSize = 1 * 1024 * 1024;
- while (objSize >= MIN_SIZE) {
- boolean sawFailure = false;
- for (int i = 0; i < SIXTEEN_MB / objSize; i++) {
- if (runtime.trackExternalAllocation(objSize)) {
- totalAllocated += objSize;
- } else {
- sawFailure = true;
- break;
- }
- }
-
- if (!sawFailure) {
- throw new RuntimeException("Test failed: " +
- "no failure while filling heap");
- }
-
- objSize = (objSize * 4) / 5;
- }
- success = true;
- } finally {
- if (!success) {
- runtime.trackExternalFree(totalAllocated);
- totalAllocated = 0;
- }
- }
- return totalAllocated;
- }
-
- public void xxtest00ExternalOomeSmall() {
- VMRuntime.getRuntime().trackExternalFree(allocateMaxExternal());
- }
-
- /**
- * Allocates as much external memory as possible, then allocates from the heap
- * until an OOME is caught.
- *
- * It's nice to run this test while the real heap is small, hence the '00' in its
- * name to force it to run before testOomeSmall().
- */
- public void xxtest00CombinedOomeSmall() {
- long totalAllocated = 0;
- boolean sawEx = false;
- try {
- totalAllocated = allocateMaxExternal();
- LinkedList<Object> list = new LinkedList<Object>();
- try {
- while (true) {
- list.add((Object)new byte[8192]);
- }
- /*NOTREACHED*/
- } catch (OutOfMemoryError oom) {
- sawEx = true;
- }
- } finally {
- VMRuntime.getRuntime().trackExternalFree(totalAllocated);
- }
- assertTrue(sawEx);
- }
-
- //TODO: test external alloc debugging/inspection
}