public async Task <object> Invoke(dynamic input) { try { string specStr = (string)input.spec; string assertionStr = (string)input.assertion; int behavior = (int)input.behavior; int engine = (int)input.engine; SpecificationBase spec = new Specification(specStr); AssertionBase assertion = spec.AssertionDatabase[assertionStr]; assertion.UIInitialize(null, behavior, engine); assertion.VerificationOutput.GenerateCounterExample = true; // assertion.VerificationMode = false; assertion.InternalStart(); return(new { statistics = assertion.GetResultString() + '\n' + assertion.GetVerificationStatistics(), type = (int)assertion.VerificationOutput.VerificationResult }); } catch (Exception e) { return(e.StackTrace); //return e.TargetSite.GetType().Name; } }
//engineIndex 0 for Depth First Search, 1 for Breadth First Search public DiagnosisResult Run() { // System.Diagnostics.Debug.WriteLine("running "+assertion); // return CreatedAtRoute("GetProduct", new { id = item.Id }, item); assertion.UIInitialize(null, fairnessIndex, engineIndex); assertion.VerificationMode = true; assertion.InternalStart(); assertion.GetVerificationStatistics(); DiagnosisResult result = new DiagnosisResult(); result.Assertion = assertion.ToString(); // System.Diagnostics.Debug.WriteLine("VALID? " + assertion.VerificationOutput.VerificationResult.Equals(VerificationResultType.VALID)); string scenarioDesc = ""; // System.Diagnostics.Debug.WriteLine("loop: " + assertion.VerificationOutput.LoopIndex); result.MemoryUsage = assertion.VerificationOutput.EstimateMemoryUsage; result.TotalTime = assertion.VerificationOutput.VerificationTime; result.NumberOfStates = assertion.VerificationOutput.NoOfStates; result.LoopIndex = assertion.VerificationOutput.LoopIndex; // System.Diagnostics.Debug.WriteLine("==totaltime: " + assertion.VerificationOutput.VerificationTime); if (assertion.VerificationOutput.VerificationResult.Equals(VerificationResultType.VALID)) { result.IsValid = true; } else { result.IsValid = false; } if (assertion.VerificationOutput.CounterExampleTrace != null) { foreach (ConfigurationBase step in assertion.VerificationOutput.CounterExampleTrace) { scenarioDesc += " " + step.GetDisplayEvent(); } result.Scenario = scenarioDesc; // System.Diagnostics.Debug.WriteLine(scenarioDesc); } // determine symthomp if (result.LoopIndex >= 0) { result.Symptom = "deadloop"; } else if (result.Scenario != null && hasDuplilcateInvoke(result.Scenario)) { result.Symptom = "livelock"; } else { result.Symptom = "normal"; } return(result); }
public List <ADLResult> Verify(ADLRequest request) { System.Diagnostics.Debug.WriteLine("request : \n" + request.code); PAT.ADL.ModuleFacade modulebase = new PAT.ADL.ModuleFacade(); SpecificationBase Spec = modulebase.ParseSpecification(request.code, string.Empty, string.Empty); System.Diagnostics.Debug.WriteLine("Specification Loaded..."); //print assertion for debugging List <KeyValuePair <string, AssertionBase> > asrtlists = Spec.AssertionDatabase.ToList(); List <ADLResult> results = new List <ADLResult>(); foreach (KeyValuePair <string, AssertionBase> asrt in asrtlists) { System.Diagnostics.Debug.WriteLine("#" + asrt.Key + "#"); // start run assertion AssertionBase assertion = asrt.Value; assertion.UIInitialize(null, 0, 0); assertion.VerificationMode = true; assertion.InternalStart(); assertion.GetVerificationStatistics(); // assertion.VerificationOutput.EstimateMemoryUsage; //System.Diagnostics.Debug.WriteLine(assertion.GetResultString()); ADLResult rs = new ADLResult(); rs.smell = asrt.Key.Substring(asrt.Key.IndexOf("-") + 1).Replace("free", ""); rs.model = request.model; if (assertion.VerificationOutput.VerificationResult.Equals(VerificationResultType.VALID)) { rs.result = "valid"; } else { rs.result = "invalid"; } rs.visitedStates = assertion.VerificationOutput.NoOfStates; rs.verificationTime = assertion.VerificationOutput.VerificationTime; rs.fullResultString = assertion.GetResultString(); results.Add(rs); } return(results); }
public List <string> VerifyModel(string model) { SpecificationBase Spec = modulebase.ParseSpecification(model, "", ""); List <string> RouteDescription = new List <string>(); try { AssertionBase assertion = Spec.AssertionDatabase.Values.ElementAt(0); assertion.UIInitialize(null, FairnessType.NO_FAIRNESS, false, false, false, true, false, false); assertion.InternalStart(); //if (assertion.VerificationOutput.VerificationResult.Equals(VerificationResultType.INVALID)) //{ // RouteDescription.Add("NoSolution"); // return RouteDescription; //} foreach (ConfigurationBase step in assertion.VerificationOutput.CounterExampleTrace) { if (step.Event != "init") { RouteDescription.Add(step.GetDisplayEvent()); } } return(RouteDescription); } catch (RuntimeException ex) { System.Console.Out.WriteLine("Runtime exception occurred: " + ex.Message); if (ex is OutOfMemoryException) { System.Console.Out.WriteLine( "This error suggests your model is too big to be verified. Please make sure all your variables are bounded. You can use domain range values to check it, e.g., \"var x:{1..100}=0;\". Alternatively you can simplify your model by using fewer events, simplier processes, and smaller constants and variables."); } else { System.Console.Out.WriteLine("Check your input model for the possiblity of errors."); } } catch (Exception ex) { System.Console.Out.WriteLine("Error occurred: " + ex.Message); } return(null); }
//engineIndex 0 for Depth First Search, 1 for Breadth First Search private DiagnosisResult RunAssertion(AssertionBase assertion, int fairnessIndex, int engineIndex) { System.Diagnostics.Debug.WriteLine(assertion); // return CreatedAtRoute("GetProduct", new { id = item.Id }, item); assertion.UIInitialize(null, fairnessIndex, engineIndex); assertion.VerificationMode = true; assertion.InternalStart(); System.Diagnostics.Debug.WriteLine(assertion.GetVerificationStatistics()); DiagnosisResult result = new DiagnosisResult(); result.Assertion = assertion.ToString(); System.Diagnostics.Debug.WriteLine("VALID? " + assertion.VerificationOutput.VerificationResult.Equals(VerificationResultType.VALID)); string scenarioDesc = ""; System.Diagnostics.Debug.WriteLine("loop: " + assertion.VerificationOutput.LoopIndex); result.MemoryUsage = assertion.VerificationOutput.EstimateMemoryUsage; result.TotalTime = assertion.VerificationOutput.VerificationTime; result.NumberOfStates = assertion.VerificationOutput.NoOfStates; result.LoopIndex = assertion.VerificationOutput.LoopIndex; if (assertion.VerificationOutput.VerificationResult.Equals(VerificationResultType.VALID)) { result.IsValid = true; } else { result.IsValid = false; } if (assertion.VerificationOutput.CounterExampleTrace != null) { foreach (ConfigurationBase step in assertion.VerificationOutput.CounterExampleTrace) { scenarioDesc += " " + step.GetDisplayEvent(); } result.Scenario = scenarioDesc; System.Diagnostics.Debug.WriteLine(scenarioDesc); } return(result); }