summaryrefslogtreecommitdiff
path: root/tools/ahat/test/DiffTest.java
diff options
context:
space:
mode:
author Richard Uhler <ruhler@google.com> 2017-09-22 10:56:22 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2017-09-22 10:56:22 +0000
commit290d692e518f44fbc1fa9ef05a8f468d37510462 (patch)
tree36294dac425bf662a9db88ab796d790d842728b5 /tools/ahat/test/DiffTest.java
parent79bbbc1c9c40478ccf752214da9574dd22cd8b02 (diff)
parent26a982ad022a254ac57f84e996c31b4e271de028 (diff)
Merge changes I9a71ea46,Ib14c294a,Id91c2be4,I3fa77e2e
* changes: Remove last remaining guava dependencies. Use a custom parser implementation instead of perflib. Remove perflib-based native allocation registry identification. ahat: Expand test coverage using static heap dumps.
Diffstat (limited to 'tools/ahat/test/DiffTest.java')
-rw-r--r--tools/ahat/test/DiffTest.java57
1 files changed, 4 insertions, 53 deletions
diff --git a/tools/ahat/test/DiffTest.java b/tools/ahat/test/DiffTest.java
index d0349fd178..585f29ae61 100644
--- a/tools/ahat/test/DiffTest.java
+++ b/tools/ahat/test/DiffTest.java
@@ -18,26 +18,7 @@ package com.android.ahat;
import com.android.ahat.heapdump.AhatHeap;
import com.android.ahat.heapdump.AhatInstance;
-import com.android.ahat.heapdump.AhatSnapshot;
-import com.android.ahat.heapdump.Diff;
-import com.android.tools.perflib.heap.hprof.HprofClassDump;
-import com.android.tools.perflib.heap.hprof.HprofConstant;
-import com.android.tools.perflib.heap.hprof.HprofDumpRecord;
-import com.android.tools.perflib.heap.hprof.HprofHeapDump;
-import com.android.tools.perflib.heap.hprof.HprofInstanceDump;
-import com.android.tools.perflib.heap.hprof.HprofInstanceField;
-import com.android.tools.perflib.heap.hprof.HprofLoadClass;
-import com.android.tools.perflib.heap.hprof.HprofPrimitiveArrayDump;
-import com.android.tools.perflib.heap.hprof.HprofRecord;
-import com.android.tools.perflib.heap.hprof.HprofRootDebugger;
-import com.android.tools.perflib.heap.hprof.HprofStaticField;
-import com.android.tools.perflib.heap.hprof.HprofStringBuilder;
-import com.android.tools.perflib.heap.hprof.HprofType;
-import com.google.common.io.ByteArrayDataOutput;
-import com.google.common.io.ByteStreams;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -93,39 +74,9 @@ public class DiffTest {
}
@Test
- public void nullClassObj() throws IOException {
- // Set up a heap dump that has a null classObj.
- // The heap dump is derived from the InstanceTest.asStringEmbedded test.
- HprofStringBuilder strings = new HprofStringBuilder(0);
- List<HprofRecord> records = new ArrayList<HprofRecord>();
- List<HprofDumpRecord> dump = new ArrayList<HprofDumpRecord>();
-
- final int stringClassObjectId = 1;
- records.add(new HprofLoadClass(0, 0, stringClassObjectId, 0, strings.get("java.lang.String")));
- dump.add(new HprofClassDump(stringClassObjectId, 0, 0, 0, 0, 0, 0, 0, 0,
- new HprofConstant[0], new HprofStaticField[0],
- new HprofInstanceField[]{
- new HprofInstanceField(strings.get("count"), HprofType.TYPE_INT),
- new HprofInstanceField(strings.get("hashCode"), HprofType.TYPE_INT),
- new HprofInstanceField(strings.get("offset"), HprofType.TYPE_INT),
- new HprofInstanceField(strings.get("value"), HprofType.TYPE_OBJECT)}));
-
- dump.add(new HprofPrimitiveArrayDump(0x41, 0, HprofType.TYPE_CHAR,
- new long[]{'n', 'o', 't', ' ', 'h', 'e', 'l', 'l', 'o', 'o', 'p'}));
-
- ByteArrayDataOutput values = ByteStreams.newDataOutput();
- values.writeInt(5); // count
- values.writeInt(0); // hashCode
- values.writeInt(4); // offset
- values.writeInt(0x41); // value
- dump.add(new HprofInstanceDump(0x42, 0, stringClassObjectId, values.toByteArray()));
- dump.add(new HprofRootDebugger(stringClassObjectId));
- dump.add(new HprofRootDebugger(0x42));
-
- records.add(new HprofHeapDump(0, dump.toArray(new HprofDumpRecord[0])));
- AhatSnapshot snapshot = SnapshotBuilder.makeSnapshot(strings, records);
-
- // Diffing should not crash.
- Diff.snapshots(snapshot, snapshot);
+ public void diffClassRemoved() throws IOException {
+ TestDump dump = TestDump.getTestDump("O.hprof", "L.hprof", null);
+ AhatHandler handler = new ObjectsHandler(dump.getAhatSnapshot());
+ TestHandler.testNoCrash(handler, "http://localhost:7100/objects?class=java.lang.Class");
}
}