use of org.evosuite.symbolic.vm.SymbolicFunctionVM in project evosuite by EvoSuite.
the class ConcolicExecution method executeConcolic.
public static List<BranchCondition> executeConcolic(DefaultTestCase defaultTestCase) {
logger.debug("Preparing concolic execution");
/**
* Prepare DSC configuration
*/
MainConfig.setInstance();
/**
* Path constraint and symbolic environment
*/
SymbolicEnvironment env = new SymbolicEnvironment(classLoader);
PathConditionCollector pc = new PathConditionCollector();
/**
* VM listeners
*/
List<IVM> listeners = new ArrayList<IVM>();
listeners.add(new CallVM(env, classLoader));
listeners.add(new JumpVM(env, pc));
listeners.add(new HeapVM(env, pc, classLoader));
listeners.add(new LocalsVM(env));
listeners.add(new ArithmeticVM(env, pc));
listeners.add(new OtherVM(env));
listeners.add(new SymbolicFunctionVM(env, pc));
VM.getInstance().setListeners(listeners);
VM.getInstance().prepareConcolicExecution();
defaultTestCase.changeClassLoader(classLoader);
SymbolicObserver symbolicExecObserver = new SymbolicObserver(env);
Set<ExecutionObserver> originalExecutionObservers = TestCaseExecutor.getInstance().getExecutionObservers();
TestCaseExecutor.getInstance().newObservers();
TestCaseExecutor.getInstance().addObserver(symbolicExecObserver);
logger.info("Starting concolic execution");
ExecutionResult result = new ExecutionResult(defaultTestCase, null);
try {
logger.debug("Executing test");
long startConcolicExecutionTime = System.currentTimeMillis();
result = TestCaseExecutor.getInstance().execute(defaultTestCase, Properties.CONCOLIC_TIMEOUT);
long estimatedConcolicExecutionTime = System.currentTimeMillis() - startConcolicExecutionTime;
DSEStats.getInstance().reportNewConcolicExecutionTime(estimatedConcolicExecutionTime);
MaxStatementsStoppingCondition.statementsExecuted(result.getExecutedStatements());
} catch (Exception e) {
logger.error("Exception during concolic execution {}", e);
return new ArrayList<BranchCondition>();
} finally {
logger.debug("Cleaning concolic execution");
TestCaseExecutor.getInstance().setExecutionObservers(originalExecutionObservers);
}
// ignore all callbacks from now on
VM.disableCallBacks();
List<BranchCondition> branches = pc.getPathCondition();
logger.info("Concolic execution ended with " + branches.size() + " branches collected");
if (!result.noThrownExceptions()) {
int idx = result.getFirstPositionOfThrownException();
logger.info("Exception thrown: " + result.getExceptionThrownAtPosition(idx));
}
logNrOfConstraints(branches);
logger.debug("Cleaning concolic execution");
TestCaseExecutor.getInstance().setExecutionObservers(originalExecutionObservers);
return branches;
}
Aggregations