Пример #1
0
 @Test
 public void testStaticInit()
     throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
   AnalysisScope scope =
       CallGraphTestUtil.makeJ2SEAnalysisScope(
           TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
   ClassHierarchy cha = ClassHierarchy.make(scope);
   Iterable<Entrypoint> entrypoints =
       com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(
           scope, cha, "LstaticInit/TestStaticInit");
   AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
   CallGraph cg = CallGraphTestUtil.buildZeroCFA(options, new AnalysisCache(), cha, scope, false);
   boolean foundDoNothing = false;
   for (CGNode n : cg) {
     if (n.toString().contains("doNothing")) {
       foundDoNothing = true;
       break;
     }
   }
   Assert.assertTrue(foundDoNothing);
   options.setHandleStaticInit(false);
   cg = CallGraphTestUtil.buildZeroCFA(options, new AnalysisCache(), cha, scope, false);
   for (CGNode n : cg) {
     Assert.assertTrue(!n.toString().contains("doNothing"));
   }
 }
Пример #2
0
 @Test
 public void testSystemProperties()
     throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
   AnalysisScope scope =
       CallGraphTestUtil.makeJ2SEAnalysisScope(
           TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
   ClassHierarchy cha = ClassHierarchy.make(scope);
   Iterable<Entrypoint> entrypoints =
       com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(
           scope, cha, "LstaticInit/TestSystemProperties");
   AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
   SSAPropagationCallGraphBuilder builder =
       Util.makeZeroCFABuilder(options, new AnalysisCache(), cha, scope);
   CallGraph cg = builder.makeCallGraph(options);
   for (CGNode n : cg) {
     if (n.toString()
         .equals(
             "Node: < Application, LstaticInit/TestSystemProperties, main([Ljava/lang/String;)V > Context: Everywhere")) {
       boolean foundToCharArray = false;
       for (CGNode callee : Iterator2Iterable.make(cg.getSuccNodes(n))) {
         if (callee.getMethod().getName().toString().equals("toCharArray")) {
           foundToCharArray = true;
           break;
         }
       }
       Assert.assertTrue(foundToCharArray);
       break;
     }
   }
 }