public GetTraversalInfo ( StateImpl InitialState, int threadId ) : |
||
InitialState | StateImpl | |
threadId | int | |
Résultat |
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); var statesExplored = new HashSet<Fingerprint>(); while (numberOfSchedulesExplored < ZingerConfiguration.MaxSchedulesPerIteration) { //increment the schedule count numberOfSchedulesExplored++; ZingerStats.IncrementNumberOfSchedules(); //random walk always starts from the start state ( no frontier ). TraversalInfo currentState = startState.Clone(); statesExplored.Clear(); while (currentState.CurrentDepth < ZingerConfiguration.MaxDepthPerSchedule) { //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; } //check if the next step is entered through a accepting transition if(nextSuccessor.IsAcceptingState && nextSuccessor.IsFingerPrinted && statesExplored.Contains(nextSuccessor.Fingerprint)) //if (nextSuccessor.IsFingerPrinted && statesExplored.Contains(nextSuccessor.Fingerprint)) { AcceptingCycles.Add(nextSuccessor.GenerateNonCompactTrace()); lastErrorFound = ZingerResult.AcceptanceCyleFound; if (ZingerConfiguration.StopOnError) throw new ZingerAcceptingCycleFound(); } //add the current state in the set. if(nextSuccessor.IsFingerPrinted) statesExplored.Add(nextSuccessor.Fingerprint); 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; } } }
protected override void SearchStateSpace(object obj) { int myThreadId = (int)obj; //maximum number of schedules per iteration = c1 + c2^d. // c1 = ZingerConfiguration.MaxSchedulesPerIteration. // c2 = 3 as we found that to work the best. int maxSchedulesPerIteration = ZingerConfiguration.MaxSchedulesPerIteration + ZingerConfiguration.zBoundedSearch.IterativeCutoff; int delayBudget = 0; Stack<TraversalInfo> searchStack = new Stack<TraversalInfo>(); //frontier FrontierNode startfN = new FrontierNode(StartStateTraversalInfo); TraversalInfo startState = startfN.GetTraversalInfo(StartStateStateImpl, myThreadId); while (ZingerConfiguration.numberOfSchedulesExplored < maxSchedulesPerIteration) { //kil the exploration if bug found //Check if cancelation token triggered if (CancelTokenZingExplorer.IsCancellationRequested) { //some task found bug and hence cancelling this task return; } delayBudget = ZingerConfiguration.zBoundedSearch.IterativeCutoff; //increment the schedule count Interlocked.Increment(ref ZingerConfiguration.numberOfSchedulesExplored); ZingerStats.IncrementNumberOfSchedules(); searchStack = new Stack<TraversalInfo>(); searchStack.Push(startState); int lastStartPoint = 1; while (delayBudget > 0) { RunToCompletionWithDelayZero(searchStack); lastStartPoint = RandomBackTrackAndDelay(searchStack, lastStartPoint); if (lastStartPoint == -1) { break; } delayBudget--; } } }