cached class hierarchy to speed things up

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3740 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
msridhar1 2009-07-27 21:03:33 +00:00
parent 02e7bf2894
commit 105a263cc5
7 changed files with 219 additions and 111 deletions

View File

@ -41,6 +41,7 @@ import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import org.junit.AfterClass;
import org.junit.Assert;
import com.ibm.wala.classLoader.IClass;
@ -66,6 +67,7 @@ import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
import com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder;
import com.ibm.wala.ipa.cha.ClassHierarchy;
import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.ssa.IR;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SSAInvokeInstruction;
@ -79,6 +81,25 @@ public abstract class AbstractPtrTest {
protected boolean debug = false;
/**
* file holding analysis scope specification
*/
protected final String scopeFile;
/**
* analysis scope from latest test
*/
private AnalysisScope scope = null;
protected AbstractPtrTest(String scopeFile) {
this.scopeFile = scopeFile;
}
private static AnalysisScope cachedScope;
private static IClassHierarchy cachedCHA;
public static CGNode findMainMethod(CallGraph cg) {
Descriptor d = Descriptor.findOrCreateUTF8("([Ljava/lang/String;)V");
Atom name = Atom.findOrCreateUnicodeAtom("main");
@ -138,15 +159,10 @@ public abstract class AbstractPtrTest {
return null;
}
/**
* analysis scope from latest test
*/
protected AnalysisScope scope = null;
protected void doPointsToSizeTest(String scopeFile, String mainClass, int expected14Size, int expected15Size, int expected16Size)
protected void doPointsToSizeTest(String mainClass, int expected14Size, int expected15Size, int expected16Size)
throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
assert scope == null;
Collection<InstanceKey> pointsTo = getPointsToSetToTest(scopeFile, mainClass);
Collection<InstanceKey> pointsTo = getPointsToSetToTest(mainClass);
if (debug) {
System.err.println("points-to for " + mainClass + ": " + pointsTo);
}
@ -164,14 +180,14 @@ public abstract class AbstractPtrTest {
scope = null;
}
protected void doPointsToSizeTest(String scopeFile, String mainClass, int expectedSize) throws ClassHierarchyException,
protected void doPointsToSizeTest(String mainClass, int expectedSize) throws ClassHierarchyException,
IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(scopeFile, mainClass, expectedSize, expectedSize, expectedSize);
doPointsToSizeTest(mainClass, expectedSize, expectedSize, expectedSize);
}
protected Collection<InstanceKey> getPointsToSetToTest(String scopeFile, String mainClass) throws ClassHierarchyException,
private Collection<InstanceKey> getPointsToSetToTest(String mainClass) throws ClassHierarchyException,
IllegalArgumentException, CancelException, IOException {
final DemandRefinementPointsTo dmp = makeDemandPointerAnalysis(scopeFile, mainClass);
final DemandRefinementPointsTo dmp = makeDemandPointerAnalysis(mainClass);
// find the testThisVar call, and check the parameter's points-to set
CGNode mainMethod = AbstractPtrTest.findMainMethod(dmp.getBaseCallGraph());
@ -180,12 +196,12 @@ public abstract class AbstractPtrTest {
return pointsTo;
}
protected DemandRefinementPointsTo makeDemandPointerAnalysis(String scopeFile, String mainClass) throws ClassHierarchyException,
protected DemandRefinementPointsTo makeDemandPointerAnalysis(String mainClass) throws ClassHierarchyException,
IllegalArgumentException, CancelException, IOException {
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(scopeFile, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
AnalysisScope scope = findOrCreateAnalysisScope();
this.scope = scope;
// build a type hierarchy
ClassHierarchy cha = ClassHierarchy.make(scope);
IClassHierarchy cha = findOrCreateCHA(scope);
// set up call graph construction options; mainly what should be considered
// entrypoints?
@ -206,6 +222,36 @@ public abstract class AbstractPtrTest {
return fullDemandPointsTo;
}
/**
* @param scope
* @return
* @throws ClassHierarchyException
*/
private IClassHierarchy findOrCreateCHA(AnalysisScope scope) throws ClassHierarchyException {
if (cachedCHA == null) {
cachedCHA = ClassHierarchy.make(scope);
}
return cachedCHA;
}
/**
* @param scopeFile
* @return
* @throws IOException
*/
private AnalysisScope findOrCreateAnalysisScope() throws IOException {
if (cachedScope == null) {
cachedScope = CallGraphTestUtil.makeJ2SEAnalysisScope(scopeFile, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
}
return cachedScope;
}
@AfterClass
public static void cleanup() {
cachedScope = null;
cachedCHA = null;
}
protected StateMachineFactory<IFlowLabel> getStateMachineFactory() {
return new DummyStateMachine.Factory<IFlowLabel>();
}

View File

@ -61,22 +61,25 @@ import com.ibm.wala.util.strings.Atom;
public class ContextSensitiveTest extends AbstractPtrTest {
public ContextSensitiveTest() {
super(TestInfo.SCOPE_FILE);
}
@Test public void testArraySet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_SET, 1);
doPointsToSizeTest(TestInfo.TEST_ARRAY_SET, 1);
}
@Test public void testClone() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_CLONE, 1);
doPointsToSizeTest(TestInfo.TEST_CLONE, 1);
}
@Test public void testFooId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ID, 1);
doPointsToSizeTest(TestInfo.TEST_ID, 1);
}
@Test public void testHashtableEnum() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
// 3 because
// can't tell between key, value, and entry enumerators in Hashtable
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_HASHTABLE_ENUM, 3);
doPointsToSizeTest(TestInfo.TEST_HASHTABLE_ENUM, 3);
}
// we know this one fails...
@ -102,7 +105,7 @@ public class ContextSensitiveTest extends AbstractPtrTest {
@Test public void testWithinMethodCall() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
String mainClass = TestInfo.TEST_WITHIN_METHOD_CALL;
final IDemandPointerAnalysis dmp = makeDemandPointerAnalysis(TestInfo.SCOPE_FILE, mainClass);
final IDemandPointerAnalysis dmp = makeDemandPointerAnalysis(mainClass);
CGNode testMethod = AbstractPtrTest.findStaticMethod(dmp.getBaseCallGraph(), Atom.findOrCreateUnicodeAtom("testMethod"),
Descriptor.findOrCreateUTF8("(Ljava/lang/Object;)V"));
@ -115,35 +118,35 @@ public class ContextSensitiveTest extends AbstractPtrTest {
}
@Test public void testLinkedListIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_LINKEDLIST_ITER, 1);
doPointsToSizeTest(TestInfo.TEST_LINKEDLIST_ITER, 1);
}
@Test public void testGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_GLOBAL, 1);
doPointsToSizeTest(TestInfo.TEST_GLOBAL, 1);
}
@Test public void testHashSet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_HASH_SET, 2, 2, 1);
doPointsToSizeTest(TestInfo.TEST_HASH_SET, 2, 2, 1);
}
@Test public void testHashMapGet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_HASHMAP_GET, 2, 1, 1);
doPointsToSizeTest(TestInfo.TEST_HASHMAP_GET, 2, 1, 1);
}
@Test public void testMethodRecursion() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_METHOD_RECURSION, 2);
doPointsToSizeTest(TestInfo.TEST_METHOD_RECURSION, 2);
}
@Test public void testArraySetIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_SET_ITER, 1);
doPointsToSizeTest(TestInfo.TEST_ARRAY_SET_ITER, 1);
}
@Test public void testArrayList() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_LIST, 1);
doPointsToSizeTest(TestInfo.TEST_ARRAY_LIST, 1);
}
@Test public void testLinkedList() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_LINKED_LIST, 1);
doPointsToSizeTest(TestInfo.TEST_LINKED_LIST, 1);
}
@Override
@ -152,8 +155,8 @@ public class ContextSensitiveTest extends AbstractPtrTest {
}
@Override
protected DemandRefinementPointsTo makeDemandPointerAnalysis(String scopeFile, String mainClass) throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
DemandRefinementPointsTo dmp = super.makeDemandPointerAnalysis(scopeFile, mainClass);
protected DemandRefinementPointsTo makeDemandPointerAnalysis(String mainClass) throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
DemandRefinementPointsTo dmp = super.makeDemandPointerAnalysis(mainClass);
dmp.setRefinementPolicyFactory(new SinglePassRefinementPolicy.Factory(new AlwaysRefineFieldsPolicy(),
new AlwaysRefineCGPolicy()));
return dmp;

View File

@ -49,8 +49,12 @@ import com.ibm.wala.util.CancelException;
public class IntraprocTest extends AbstractPtrTest {
public IntraprocTest() {
super(TestInfo.SCOPE_FILE);
}
@Test public void testId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ID, 0);
doPointsToSizeTest(TestInfo.TEST_ID, 0);
}
@Override

View File

@ -46,60 +46,78 @@ import com.ibm.wala.util.CancelException;
public class NoRefinePtrTest extends AbstractPtrTest {
@Test public void testOnTheFlySimple() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ONTHEFLY_SIMPLE, 1);
public NoRefinePtrTest() {
super(TestInfo.SCOPE_FILE);
}
@Test public void testArraySet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_SET, 2);
@Test
public void testOnTheFlySimple() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_ONTHEFLY_SIMPLE, 1);
}
@Test public void testArraySetIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_SET_ITER, 2);
@Test
public void testArraySet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_ARRAY_SET, 2);
}
@Test public void testHashSet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_HASH_SET, 3, 3, 2);
@Test
public void testArraySetIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_ARRAY_SET_ITER, 2);
}
@Test public void testMethodRecursion() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_METHOD_RECURSION, 2);
@Test
public void testHashSet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_HASH_SET, 3, 3, 2);
}
@Test public void testFooId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ID, 2);
@Test
public void testMethodRecursion() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_METHOD_RECURSION, 2);
}
@Test public void testLocals() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_LOCALS, 1);
@Test
public void testFooId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_ID, 2);
}
@Test public void testArrays() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAYS, 2);
@Test
public void testLocals() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_LOCALS, 1);
}
@Test public void testFields() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_FIELDS, 2);
@Test
public void testArrays() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_ARRAYS, 2);
}
@Test public void testFieldsHarder() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_FIELDS_HARDER, 2);
@Test
public void testFields() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_FIELDS, 2);
}
@Test public void testGetterSetter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_GETTER_SETTER, 2);
@Test
public void testFieldsHarder() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_FIELDS_HARDER, 2);
}
@Test public void testException() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_EXCEPTION, 4);
@Test
public void testGetterSetter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_GETTER_SETTER, 2);
}
@Test public void testMultiDim() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_MULTI_DIM, 2);
@Test
public void testException() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_EXCEPTION, 4);
}
@Test public void testGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_GLOBAL, 1);
@Test
public void testMultiDim() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_MULTI_DIM, 2);
}
@Test
public void testGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_GLOBAL, 1);
}
}

View File

@ -50,13 +50,19 @@ import com.ibm.wala.util.CancelException;
public class OnTheFlyPtrTest extends AbstractPtrTest {
@Test public void testOnTheFlySimple() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ONTHEFLY_SIMPLE, 1);
public OnTheFlyPtrTest() {
super(TestInfo.SCOPE_FILE);
}
@Test
public void testOnTheFlySimple() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_ONTHEFLY_SIMPLE, 1);
}
@Override
protected DemandRefinementPointsTo makeDemandPointerAnalysis(String scopeFile, String mainClass) throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
DemandRefinementPointsTo dmp = super.makeDemandPointerAnalysis(scopeFile, mainClass);
protected DemandRefinementPointsTo makeDemandPointerAnalysis(String mainClass) throws ClassHierarchyException,
IllegalArgumentException, CancelException, IOException {
DemandRefinementPointsTo dmp = super.makeDemandPointerAnalysis(mainClass);
dmp.setRefinementPolicyFactory(new SinglePassRefinementPolicy.Factory(new AlwaysRefineFieldsPolicy(),
new AlwaysRefineCGPolicy()));
return dmp;

View File

@ -50,46 +50,59 @@ import com.ibm.wala.util.CancelException;
public class RefineFieldsPtrTest extends AbstractPtrTest {
@Test public void testNastyPtrs() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_NASTY_PTRS, 10);
public RefineFieldsPtrTest() {
super(TestInfo.SCOPE_FILE);
}
@Test public void testGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_GLOBAL, 1);
@Test
public void testNastyPtrs() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_NASTY_PTRS, 10);
}
@Test public void testFields() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_FIELDS, 1);
@Test
public void testGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_GLOBAL, 1);
}
@Test public void testFieldsHarder() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_FIELDS_HARDER, 1);
@Test
public void testFields() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_FIELDS, 1);
}
@Test public void testArrays() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAYS, 2);
@Test
public void testFieldsHarder() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_FIELDS_HARDER, 1);
}
@Test public void testGetterSetter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_GETTER_SETTER, 1);
@Test
public void testArrays() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_ARRAYS, 2);
}
@Test public void testArraySet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_SET, 2);
@Test
public void testGetterSetter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_GETTER_SETTER, 1);
}
@Test public void testArraySetIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_SET_ITER, 2);
@Test
public void testArraySet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_ARRAY_SET, 2);
}
@Test public void testMultiDim() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_MULTI_DIM, 2);
@Test
public void testArraySetIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_ARRAY_SET_ITER, 2);
}
@Test
public void testMultiDim() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_MULTI_DIM, 2);
}
@Override
public DemandRefinementPointsTo makeDemandPointerAnalysis(String scopeFile, String mainClass) throws ClassHierarchyException,
public DemandRefinementPointsTo makeDemandPointerAnalysis(String mainClass) throws ClassHierarchyException,
IllegalArgumentException, CancelException, IOException {
DemandRefinementPointsTo dmp = super.makeDemandPointerAnalysis(scopeFile, mainClass);
DemandRefinementPointsTo dmp = super.makeDemandPointerAnalysis(mainClass);
dmp
.setRefinementPolicyFactory(new SinglePassRefinementPolicy.Factory(new AlwaysRefineFieldsPolicy(),
new NeverRefineCGPolicy()));

View File

@ -32,22 +32,31 @@ import com.ibm.wala.util.strings.Atom;
public class TunedRefinementTest extends AbstractPtrTest {
@Test public void testArraySet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_SET, 1);
public TunedRefinementTest() {
super(TestInfo.SCOPE_FILE);
// TODO Auto-generated constructor stub
}
@Test public void testClone() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_CLONE, 1);
@Test
public void testArraySet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_ARRAY_SET, 1);
}
@Test public void testFooId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ID, 1);
@Test
public void testClone() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_CLONE, 1);
}
@Test public void testHashtableEnum() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
@Test
public void testFooId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_ID, 1);
}
@Test
public void testHashtableEnum() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
// 3 because
// can't tell between key, value, and entry enumerators in Hashtable
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_HASHTABLE_ENUM, 3);
doPointsToSizeTest(TestInfo.TEST_HASHTABLE_ENUM, 3);
}
// we know this one fails...
@ -71,9 +80,10 @@ public class TunedRefinementTest extends AbstractPtrTest {
// assertEquals(1, pointsTo.size());
// }
@Test public void testWithinMethodCall() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
@Test
public void testWithinMethodCall() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
String mainClass = TestInfo.TEST_WITHIN_METHOD_CALL;
final IDemandPointerAnalysis dmp = makeDemandPointerAnalysis(TestInfo.SCOPE_FILE, mainClass);
final IDemandPointerAnalysis dmp = makeDemandPointerAnalysis(mainClass);
CGNode testMethod = AbstractPtrTest.findStaticMethod(dmp.getBaseCallGraph(), Atom.findOrCreateUnicodeAtom("testMethod"),
Descriptor.findOrCreateUTF8("(Ljava/lang/Object;)V"));
@ -85,36 +95,44 @@ public class TunedRefinementTest extends AbstractPtrTest {
Assert.assertEquals(1, pointsTo.size());
}
@Test public void testLinkedListIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_LINKEDLIST_ITER, 1);
@Test
public void testLinkedListIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_LINKEDLIST_ITER, 1);
}
@Test public void testGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_GLOBAL, 1);
@Test
public void testGlobal() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_GLOBAL, 1);
}
@Test public void testHashSet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_HASH_SET, 2, 2, 1);
@Test
public void testHashSet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_HASH_SET, 2, 2, 1);
}
@Test public void testHashMapGet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_HASHMAP_GET, 2, 1, 1);
@Test
public void testHashMapGet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_HASHMAP_GET, 2, 1, 1);
}
@Test public void testMethodRecursion() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_METHOD_RECURSION, 2);
@Test
public void testMethodRecursion() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_METHOD_RECURSION, 2);
}
@Test public void testArraySetIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_SET_ITER, 1);
@Test
public void testArraySetIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_ARRAY_SET_ITER, 1);
}
@Test public void testArrayList() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_ARRAY_LIST, 1);
@Test
public void testArrayList() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_ARRAY_LIST, 1);
}
@Test public void testLinkedList() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.SCOPE_FILE, TestInfo.TEST_LINKED_LIST, 1);
@Test
public void testLinkedList() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
doPointsToSizeTest(TestInfo.TEST_LINKED_LIST, 1);
}
@Override
@ -122,10 +140,10 @@ public class TunedRefinementTest extends AbstractPtrTest {
return new ContextSensitiveStateMachine.Factory();
}
@Override
protected DemandRefinementPointsTo makeDemandPointerAnalysis(String scopeFile, String mainClass) throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
DemandRefinementPointsTo dmp = super.makeDemandPointerAnalysis(scopeFile, mainClass);
protected DemandRefinementPointsTo makeDemandPointerAnalysis(String mainClass) throws ClassHierarchyException,
IllegalArgumentException, CancelException, IOException {
DemandRefinementPointsTo dmp = super.makeDemandPointerAnalysis(mainClass);
dmp.setRefinementPolicyFactory(new TunedRefinementPolicy.Factory(dmp.getClassHierarchy()));
return dmp;
}