From 93a4571961f9c00b9025e80bdd587e48538ab752 Mon Sep 17 00:00:00 2001 From: msridhar1 Date: Mon, 27 Jul 2009 22:43:06 +0000 Subject: [PATCH] undo WalaTestCase extending TestCase; dependent projects will have to be switched to JUnit 4. Also, more optimizations. git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3742 f5eafffb-2e1d-0410-98e4-8ec43c5233c4 --- .../core/tests/basic/GraphDataflowTest.java | 4 - .../wala/core/tests/basic/PrimitivesTest.java | 7 -- .../tests/callGraph/CallGraphTestUtil.java | 84 +++++++++++++------ .../wala/core/tests/cha/GetTargetsTest.java | 16 ++-- .../core/tests/ir/DeterministicIRTest.java | 22 ++--- .../core/tests/ptrs/MultiDimArrayTest.java | 7 +- .../wala/core/tests/util/WalaTestCase.java | 15 +--- 7 files changed, 81 insertions(+), 74 deletions(-) diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/GraphDataflowTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/GraphDataflowTest.java index 9274805ba..6900d61ea 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/GraphDataflowTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/GraphDataflowTest.java @@ -40,10 +40,6 @@ public class GraphDataflowTest extends WalaTestCase { public static final String nodeNames = "ABCDEFGH"; protected final static String[] nodes = new String[nodeNames.length()]; - public GraphDataflowTest() { - super("GraphDataflowTest"); - } - /** * A simple test of the GraphBitVectorDataflow system * @throws CancelException diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/PrimitivesTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/PrimitivesTest.java index d8368856a..d633dc276 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/PrimitivesTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/PrimitivesTest.java @@ -60,13 +60,6 @@ import com.ibm.wala.util.intset.SparseLongSet; */ public class PrimitivesTest extends WalaTestCase { - public PrimitivesTest() { - super("PrimitivesTest"); - } - - public PrimitivesTest(String arg0) { - super(arg0); - } /** * Test the MutableSparseIntSet implementation diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTestUtil.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTestUtil.java index 15f6c6d50..3f8fe3d94 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTestUtil.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTestUtil.java @@ -32,7 +32,6 @@ public class CallGraphTestUtil { private static final ClassLoader MY_CLASSLOADER = CallGraphTestUtil.class.getClassLoader(); - public static AnalysisOptions makeAnalysisOptions(AnalysisScope scope, Iterable entrypoints) { AnalysisOptions options = new AnalysisOptions(scope, entrypoints); return options; @@ -40,6 +39,11 @@ public class CallGraphTestUtil { public static String REGRESSION_EXCLUSIONS = "Java60RegressionExclusions.txt"; + /** + * should we check the heap footprint before and after CG construction? + */ + private static final boolean CHECK_FOOTPRINT = false; + public static AnalysisScope makeJ2SEAnalysisScope(String scopeFile, String exclusionsFile) throws IOException { AnalysisScope scope = AnalysisScopeReader.readJavaScope(scopeFile, FileProvider.getFile(exclusionsFile), MY_CLASSLOADER); return scope; @@ -47,21 +51,29 @@ public class CallGraphTestUtil { public static CallGraph buildRTA(AnalysisOptions options, AnalysisCache cache, ClassHierarchy cha, AnalysisScope scope) throws IllegalArgumentException, CancelException { - StopwatchGC S = new StopwatchGC("build RTA graph"); - S.start(); + StopwatchGC S = null; + if (CHECK_FOOTPRINT) { + S = new StopwatchGC("build RTA graph"); + S.start(); + } CallGraphBuilder builder = Util.makeRTABuilder(options, cache, cha, scope); CallGraph cg = builder.makeCallGraph(options, null); - S.stop(); - System.err.println(S.report()); + if (CHECK_FOOTPRINT) { + S.stop(); + System.err.println(S.report()); + } return cg; } public static CallGraph buildZeroCFA(AnalysisOptions options, AnalysisCache cache, ClassHierarchy cha, AnalysisScope scope, boolean testPAtoString) throws IllegalArgumentException, CancelException { - StopwatchGC S = new StopwatchGC("build ZeroCFA graph"); - S.start(); + StopwatchGC S = null; + if (CHECK_FOOTPRINT) { + S = new StopwatchGC("build RTA graph"); + S.start(); + } CallGraphBuilder builder = Util.makeZeroCFABuilder(options, cache, cha, scope); CallGraph cg = builder.makeCallGraph(options, null); @@ -69,28 +81,38 @@ public class CallGraphTestUtil { builder.getPointerAnalysis().toString(); } - S.stop(); - System.err.println(S.report()); + if (CHECK_FOOTPRINT) { + S.stop(); + System.err.println(S.report()); + } return cg; } public static CallGraph buildVanillaZeroOneCFA(AnalysisOptions options, AnalysisCache cache, ClassHierarchy cha, AnalysisScope scope) throws IllegalArgumentException, CancelException { - StopwatchGC S = new StopwatchGC("build Vanilla 0-1-CFA graph"); - S.start(); + StopwatchGC S = null; + if (CHECK_FOOTPRINT) { + S = new StopwatchGC("build RTA graph"); + S.start(); + } CallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(options, cache, cha, scope); CallGraph cg = builder.makeCallGraph(options, null); - S.stop(); - System.err.println(S.report()); + if (CHECK_FOOTPRINT) { + S.stop(); + System.err.println(S.report()); + } return cg; } public static CallGraph buildZeroOneCFA(AnalysisOptions options, AnalysisCache cache, ClassHierarchy cha, AnalysisScope scope, boolean testPAtoString) throws IllegalArgumentException, CancelException { - StopwatchGC S = new StopwatchGC("build 0-1-CFA graph"); - S.start(); + StopwatchGC S = null; + if (CHECK_FOOTPRINT) { + S = new StopwatchGC("build RTA graph"); + S.start(); + } CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cache, cha, scope); CallGraph cg = builder.makeCallGraph(options, null); @@ -98,34 +120,46 @@ public class CallGraphTestUtil { builder.getPointerAnalysis().toString(); } - S.stop(); - System.err.println(S.report()); + if (CHECK_FOOTPRINT) { + S.stop(); + System.err.println(S.report()); + } return cg; } public static CallGraph buildZeroContainerCFA(AnalysisOptions options, AnalysisCache cache, ClassHierarchy cha, AnalysisScope scope) throws IllegalArgumentException, CancelException { - StopwatchGC S = new StopwatchGC("build 0-1-Container-CFA graph"); - S.start(); + StopwatchGC S = null; + if (CHECK_FOOTPRINT) { + S = new StopwatchGC("build RTA graph"); + S.start(); + } CallGraphBuilder builder = Util.makeZeroContainerCFABuilder(options, cache, cha, scope); CallGraph cg = builder.makeCallGraph(options, null); - S.stop(); - System.err.println(S.report()); + if (CHECK_FOOTPRINT) { + S.stop(); + System.err.println(S.report()); + } return cg; } public static CallGraph buildZeroOneContainerCFA(AnalysisOptions options, AnalysisCache cache, ClassHierarchy cha, AnalysisScope scope) throws IllegalArgumentException, CancelException { - StopwatchGC S = new StopwatchGC("build 0-1-Container-CFA graph"); - S.start(); + StopwatchGC S = null; + if (CHECK_FOOTPRINT) { + S = new StopwatchGC("build RTA graph"); + S.start(); + } CallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope); CallGraph cg = builder.makeCallGraph(options, null); - S.stop(); - System.err.println(S.report()); + if (CHECK_FOOTPRINT) { + S.stop(); + System.err.println(S.report()); + } return cg; } diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/GetTargetsTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/GetTargetsTest.java index f7c209155..bb6e1d662 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/GetTargetsTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/GetTargetsTest.java @@ -12,9 +12,9 @@ package com.ibm.wala.core.tests.cha; import java.util.Collection; -import org.junit.After; +import org.junit.AfterClass; import org.junit.Assert; -import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import com.ibm.wala.classLoader.ClassLoaderFactory; @@ -38,15 +38,15 @@ public class GetTargetsTest extends WalaTestCase { private static final ClassLoader MY_CLASSLOADER = GetTargetsTest.class.getClassLoader(); - private AnalysisScope scope; - private ClassHierarchy cha; + private static AnalysisScope scope; + private static ClassHierarchy cha; public static void main(String[] args) { justThisTest(GetTargetsTest.class); } - @Before - public void setUp() throws Exception { + @BeforeClass + public static void beforeClass() throws Exception { scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); @@ -64,8 +64,8 @@ public class GetTargetsTest extends WalaTestCase { * * @see junit.framework.TestCase#tearDown() */ - @After - public void tearDown() throws Exception { + @AfterClass + public static void afterClass() throws Exception { scope = null; cha = null; } diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/DeterministicIRTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/DeterministicIRTest.java index ad3fbacd1..981599d37 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/DeterministicIRTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/DeterministicIRTest.java @@ -12,9 +12,9 @@ package com.ibm.wala.core.tests.ir; import java.util.Iterator; -import org.junit.After; +import org.junit.AfterClass; import org.junit.Assert; -import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import com.ibm.wala.classLoader.ClassLoaderFactory; @@ -50,20 +50,20 @@ public class DeterministicIRTest extends WalaTestCase { private static final ClassLoader MY_CLASSLOADER = DeterministicIRTest.class.getClassLoader(); - private AnalysisScope scope; + private static AnalysisScope scope; - private ClassHierarchy cha; + private static ClassHierarchy cha; - private AnalysisOptions options; + private static AnalysisOptions options; - private AnalysisCache cache; + private static AnalysisCache cache; public static void main(String[] args) { justThisTest(DeterministicIRTest.class); } - @Before - public void setUp() throws Exception { + @BeforeClass + public static void beforeClass() throws Exception { scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, FileProvider.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); @@ -78,11 +78,13 @@ public class DeterministicIRTest extends WalaTestCase { } } - @After - public void tearDown() throws Exception { + @AfterClass + public static void afterClass() throws Exception { Warnings.clear(); scope = null; cha = null; + options = null; + cache = null; } /** diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ptrs/MultiDimArrayTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ptrs/MultiDimArrayTest.java index 7ec9aa7e6..8fcf0cb9e 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ptrs/MultiDimArrayTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ptrs/MultiDimArrayTest.java @@ -50,12 +50,7 @@ public class MultiDimArrayTest extends WalaTestCase { justThisTest(MultiDimArrayTest.class); } - /** - * @param arg0 - */ - public MultiDimArrayTest(String arg0) { - super(arg0); - } + public MultiDimArrayTest() { diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/util/WalaTestCase.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/util/WalaTestCase.java index 4c40f6a74..4f57ff02e 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/util/WalaTestCase.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/util/WalaTestCase.java @@ -10,8 +10,6 @@ *******************************************************************************/ package com.ibm.wala.core.tests.util; -import junit.framework.TestCase; - import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -23,7 +21,7 @@ import com.ibm.wala.util.warnings.Warnings; /** * Simple extension to JUnit test case. */ -public abstract class WalaTestCase extends TestCase { +public abstract class WalaTestCase { final private static boolean ANALYZE_LEAKS = false; @@ -62,17 +60,6 @@ public abstract class WalaTestCase extends TestCase { JUnitCore.runClasses(testClass); } - /** - * @param arg0 - */ - public WalaTestCase(String arg0) { - super(arg0); - } - - public WalaTestCase() { - this("WalaTestCase"); - } - protected static void assertBound(String tag, double quantity, double bound) { String msg = tag + ", quantity: " + quantity + ", bound:" + bound; System.err.println(msg);