protected virtual void VerificationFinished() { try { if (Utility.Utilities.IsValidLicenseAvailable == Utility.Utilities.LicenseType.Evaluation || Utility.Utilities.IsValidLicenseAvailable == Utility.Utilities.LicenseType.Invalid) { if (mAssertion.VerificationOutput.NoOfStates > Utility.Utilities.LicenseBoundedStateNumber) { mListener.updateResFinishedVerify(); mListener.updateStatusLabel(Resources.Verification_Completed); mAssertion.Clear(); //remove the events mAssertion.Action -= mListener.onAction; mAssertion.Cancelled -= Verification_Cancelled; mAssertion.ReturnResult -= VerificationFinished; mAssertion.Failed -= MC_Failed; mListener.enableAllControls(); mTimer.Stop(); return; } } mListener.onAction(mAssertion.GetVerificationStatistics()); mListener.onResult(mAssertion.VerificationOutput.VerificationResult); mListener.updateStatusLabel(Resources.Generating_Result); mAssertion.ReturnResult -= VerificationFinished; mAssertion.ReturnResult += VerificationResult; mAssertion.VerificationOutput.GenerateCounterExample = mListener.generateCounterExample(); mAssertion.VerificationMode = false; mAssertion.Start(); } catch (Exception ex) { mAssertion.Clear(); //remove the events mAssertion.Action -= mListener.onAction; mAssertion.Cancelled -= Verification_Cancelled; mAssertion.ReturnResult -= VerificationFinished; mAssertion.Failed -= MC_Failed; mSpec.AssertionDatabase[mCurAssert] = mAssertion; Common.Utility.Utilities.LogException(ex, mSpec); } // Add by Minh //mListener.RnderingOutputTextbox(); mSpec.UnLockSharedData(); mSpec.UnLockSpecificationData(); }
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); }
//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); }
protected virtual void MC_Failed(object sender, System.Threading.ThreadExceptionEventArgs e) { try { if (e.Exception is RuntimeException) { Common.Ultility.Ultility.LogRuntimeException(e.Exception as RuntimeException); //string trace = ""; //if (e.Exception.Data.Contains("trace")) //{ // trace = Environment.NewLine + "Trace leads to exception:" + Environment.NewLine + e.Exception.Data["trace"].ToString(); //} if (Assertion != null) { TextBox_Output.Text = Assertion.GetVerificationStatistics() + TextBox_Output.Text; TextBox_Output.Text = Assertion.VerificationOutput.ResultString + TextBox_Output.Text; RnderingOutputTextbox(); //TextBox_Output.Text = Resources.Total_transitions_visited_before_the_exception + Assertion.VerificationOutput.Transitions + Environment.NewLine + TextBox_Output.Text; } //TextBox_Output.Text += e.Exception.StackTrace + "\r\n" + TextBox_Output.Text; //TextBox_Output.Text = e.Exception.Message + trace + Environment.NewLine + TextBox_Output.Text; //TextBox_Output.Text = Resources.Exception_happened_during_the_verification + ":\r\n" + TextBox_Output.Text; StatusLabel_Text.Text = Resources.Runtime_Exception_Happened; } else { //if the button is enabled -> the failure is not triggered by cancel action. if (Button_Verify.Enabled) { Common.Ultility.Ultility.LogException(e.Exception, Spec); Spec.UnLockSharedData(); this.Close(); } else { this.StatusLabel_Text.Text = Resources.Verification_Cancelled; } } if (Assertion != null) { Assertion.Clear(); //remove the events Assertion.Action -= OnAction; Assertion.ReturnResult -= VerificationFinished; Assertion.Cancelled -= Verification_Cancelled; Assertion.Failed -= MC_Failed; Assertion = null; } EnableAllControls(); } catch (Exception ex) { Common.Ultility.Ultility.LogException(ex, Spec); //MessageBox.Show("Exception happened: " + ex.Message + "\r\n", // + ex.StackTrace,"PAT", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected virtual void VerificationFinished() { try { //timer.Stop(); //MCTimer.Stop(); //long stopMemorySize = System.GC.GetTotalMemory(false); //TextBox_Output.Text = "Estimated Memory Used:" + (stopMemorySize - startMemroySize) / 1000.0 + "KB\r\n\r\n" + TextBox_Output.Text; //TextBox_Output.Text = "Time Used:" + timer.Elapsed.TotalSeconds + "s\r\n" + TextBox_Output.Text; //if(DBM.TimerNumber > 0) //{ // TextBox_Output.Text = "Number of Clocks Used: " + DBM.TimerNumber + "\r\n" + TextBox_Output.Text; //} //if (this.CheckBox_Parallel.Checked && Assertion is AssertionLTL) //{ // AssertionLTL ltl = Assertion as AssertionLTL; // TextBox_Output.Text = "SCC Ratio: " + Math.Round(((double)ltl.SCCTotalSize / (double)Assertion.VerificationOutput.NoOfStates), 2).ToString() + "\r\n" + TextBox_Output.Text; //DataStore.DataManager.GetNoOfStates() // if (ltl.SCCCount != 0) // { // TextBox_Output.Text = "Average SCC Size: " + (ltl.SCCTotalSize / ltl.SCCCount) + "\r\n" + TextBox_Output.Text; // } // else // { // TextBox_Output.Text = "Average SCC Size: 0\r\n" + TextBox_Output.Text; // } // TextBox_Output.Text = "Total SCC states: " + ltl.SCCTotalSize + "\r\n" + TextBox_Output.Text; // TextBox_Output.Text = "Number of SCC found: " + ltl.SCCCount + "\r\n" + TextBox_Output.Text; //} //TextBox_Output.Text = "Total Transitions:" + Assertion.VerificationOutput.Transitions + "\r\n" + TextBox_Output.Text; //string group = ""; //if (Assertion.VerificationOutput.NoOfGroupedStates > 0) //{ // group = " (" + Assertion.VerificationOutput.NoOfGroupedStates + " states are grouped)"; //} //TextBox_Output.Text = "Visited States:" + Assertion.VerificationOutput.NoOfStates + group + "\r\n" + TextBox_Output.Text; //DataStore.DataManager.GetNoOfStates() //TextBox_Output.Text = "********Verification Statistics********\r\n" + TextBox_Output.Text; TextBox_Output.Text = Assertion.GetVerificationStatistics() + TextBox_Output.Text; //if(CheckBox_GenerateCounterexample.Checked) //{ StatusLabel_Text.Text = Resources.Generating_Result___; Assertion.ReturnResult -= VerificationFinished; Assertion.ReturnResult += VerificationResult; Assertion.VerificationMode = false; Assertion.Start(); //} //else //{ // StatusLabel_Text.Text = Resources.Verification_Completed; // StartVerification(true, true); //} } catch (Exception ex) { Assertion.Clear(); //remove the events Assertion.Action -= OnAction; Assertion.Cancelled -= Verification_Cancelled; Assertion.ReturnResult -= VerificationFinished; Assertion.Failed -= MC_Failed; Common.Utility.Utilities.LogException(ex, Spec); //MessageBox.Show("Exception happened during verification: " + ex.Message + "\r\n" + ex.StackTrace, "PAT", MessageBoxButtons.OK, MessageBoxIcon.Error); } }