public void DisallowedSpeculativeExecutionPath() { p = LoadProgramFrom("programs/TwoPaths.bpl"); // By using a dummy solver which always returns "UNKNOWN" every path should // be consider to be speculative e = GetExecutor(p, new DFSStateScheduler(), new SimpleSolver(new DummySolver(Result.UNKNOWN))); int counter = 0; ITerminationType terminationType = null; e.StateTerminated += delegate(object sender, Executor.ExecutionStateEventArgs stateArgs) { terminationType = stateArgs.State.TerminationType; Assert.IsInstanceOf <TerminatedWithDisallowedSpeculativePath>(terminationType); ++counter; Assert.IsTrue(stateArgs.State.Speculative); }; e.Run(GetMain(p)); Assert.AreEqual(2, counter); // Check Terminations statistic Assert.AreEqual(1, terminationType.ExitLocation.InstrStatistics.Terminations); }
// Don't use this directly! Use the Executor.TerminateState() instead! public void Terminate(ITerminationType tt) { Debug.Assert(tt != null, "ITerminationType cannot be null"); this.TerminationType = tt; (tt as dynamic).State = this; // Public interface doesn't allow state to be changed so cast to actual type so we can set. // FIXME: Add some checks to make sure the termination type corresponds // with the current instruction }
public void UnexplorableGotos() { p = LoadProgramFrom("programs/GotoUnsatTargets.bpl"); e = GetExecutor(p, new DFSStateScheduler(), GetSolver()); e.UseGotoLookAhead = true; int counter = 0; ITerminationType terminationType = null; e.StateTerminated += delegate(object sender, Executor.ExecutionStateEventArgs executionStateEventArgs) { Assert.IsInstanceOf <TerminatedAtGotoWithUnsatisfiableTargets>(executionStateEventArgs.State.TerminationType); terminationType = executionStateEventArgs.State.TerminationType; ++counter; Assert.IsFalse(executionStateEventArgs.State.Speculative); }; e.Run(GetMain(p)); Assert.AreEqual(1, counter); Assert.AreEqual(1, terminationType.ExitLocation.AsTransferCmd.GetInstructionStatistics().Terminations); }