protected override void SearchStateSpace(object obj)
{
int myThreadId = (int)obj;
int numberOfSchedulesExplored = 0;
//frontier
FrontierNode startfN = new FrontierNode(StartStateTraversalInfo);
TraversalInfo startState = startfN.GetTraversalInfo(StartStateStateImpl, myThreadId);
while (numberOfSchedulesExplored < ZingerConfiguration.MaxSchedulesPerIteration)
{
//increment the schedule count
numberOfSchedulesExplored++;
ZingerStats.IncrementNumberOfSchedules();
//random walk always starts from the start state ( no frontier ).
TraversalInfo currentState = startState;
while (currentState.CurrentDepth < ZingerConfiguration.zBoundedSearch.IterativeCutoff)
{
//kil the exploration if bug found
//Check if cancelation token triggered
if (CancelTokenZingExplorer.IsCancellationRequested)
{
//some task found bug and hence cancelling this task
return;
}
ZingerStats.MaxDepth = Math.Max(ZingerStats.MaxDepth, currentState.CurrentDepth);
//Check if the DFS Stack Overflow has occured.
if (currentState.CurrentDepth > ZingerConfiguration.BoundDFSStackLength)
{
//update the safety traces
SafetyErrors.Add(currentState.GenerateNonCompactTrace());
// return value
this.lastErrorFound = ZingerResult.DFSStackOverFlowError;
throw new ZingerDFSStackOverFlow();
}
TraversalInfo nextSuccessor = currentState.GetNextSuccessorUniformRandomly();
ZingerStats.IncrementTransitionsCount();
ZingerStats.IncrementStatesCount();
if (nextSuccessor == null)
{
break;
}
TerminalState terminalState = nextSuccessor as TerminalState;
if (terminalState != null)
{
if (terminalState.IsErroneousTI)
{
lock (SafetyErrors)
{
// bugs found
SafetyErrors.Add(nextSuccessor.GenerateNonCompactTrace());
this.lastErrorFound = nextSuccessor.ErrorCode;
}
if (ZingerConfiguration.StopOnError)
{
CancelTokenZingExplorer.Cancel(true);
throw nextSuccessor.Exception;
}
}
break;
}
currentState = nextSuccessor;
}
}
}