1 package gov.nasa.jpf.search; 20 21 22 import gov.nasa.jpf.*; 23 import gov.nasa.jpf.util.Debug; 24 25 26 33 public class RandomSearch extends AbstractSearch { 34 int path_limit = 0; 35 36 public RandomSearch (Config config, VM vm) { 37 super(config, vm); 38 39 path_limit = config.getInt("search.RandomSearch.path_limit", 0); 40 41 System.out.println("Path Limit = " + path_limit); 42 43 Debug.println(Debug.WARNING, "Random Search"); 44 } 45 46 public void search () { 47 int depth = 0; 48 int paths = 0; 49 depth++; 50 51 if (hasPropertyTermination()) { 52 return; 53 } 54 55 vm.forward(); 56 VMState init_state = vm.getState(); 57 init_state.makeRestorable(); 58 59 notifySearchStarted(); 60 while (!done) { 61 if (vm.forward()) { 62 notifyStateAdvanced(); 63 if (hasPropertyTermination()) { 64 return; 65 } 66 depth++; 67 } else { isPropertyViolated(); 71 done = (paths >= path_limit); 72 paths++; 73 System.out.println("paths = " + paths); 74 depth = 1; 75 vm.restoreState(init_state); 76 } 78 } 79 notifySearchFinished(); 80 } 81 } 82 | Popular Tags |