Example #1
0
        private void StartVerification(ListViewItem item)
        {
            if (!ModuleSpecificCheckPassed())
            {
                return;
            }

            if (!Spec.GrabSharedDataLock())
            {
                MessageBox.Show(Resources.Please_wait_for_the_simulation_or_parsing_finished_before_verification, Common.Ultility.Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            DisableAllControls();


            try
            {
                Spec.LockSharedData(false);

                StatusLabel_Text.Text = Resources.ModelCheckingForm_StartVerification_Verification_Starts;



                item.ImageIndex = UNKNOWN_ICON;

                Assertion = Spec.AssertionDatabase[item.SubItems[2].Text];
                Assertion.UIInitialize(this, ComboBox_AdmissibleBehavior.SelectedIndex == -1 ? 0 : ComboBox_AdmissibleBehavior.SelectedIndex,
                                       ComboBox_VerificationEngine.SelectedIndex == -1 ? 0 : ComboBox_VerificationEngine.SelectedIndex);

                Assertion.VerificationOutput.GenerateCounterExample = CheckBox_GenerateWitnessTrace.Checked;

                Assertion.Action       += OnAction;
                Assertion.ReturnResult += VerificationFinished;
                Assertion.Cancelled    += Verification_Cancelled;
                Assertion.Failed       += MC_Failed;

                seconds           = 1;
                ProgressBar.Value = 0;
                MCTimer.Start();
                Assertion.Start();
            }
            catch (RuntimeException e)
            {
                Spec.UnLockSharedData();
                Common.Ultility.Ultility.LogRuntimeException(e);
                Button_Verify.Text = VERIFY;
                this.Close();
                return;
            }
            catch (Exception ex)
            {
                Spec.UnLockSharedData();
                Common.Ultility.Ultility.LogException(ex, Spec);
                Button_Verify.Text = VERIFY;
                this.Close();
                return;
            }
        }
Example #2
0
    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;
        }
    }
Example #3
0
        //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);
        }
Example #4
0
        public void startVerification(string assert)
        {
            do
            {
                mCurAssert = assert;
                if (!mListener.moduleSpecificCheckPassed())
                {
                    break;
                }

                if (!mSpec.GrabSharedDataLock())
                {
                    MessageBox.Show(Resources.Please_wait_for_the_simulation_or_parsing_finished_before_verification, Common.Utility.Utilities.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }

                mListener.disableAllControls();
                try
                {
                    mSpec.LockSharedData(false);

                    mListener.updateStatusLabel(Resources.ModelCheckingForm_StartVerification_Verification_Starts);
                    mListener.updateResStartVerify();

                    mAssertion = mSpec.AssertionDatabase[assert];

                    int admissibleIndex         = mListener.getCmbAdmissibleIndex();
                    int verificationEngineIndex = mListener.getCmbVerificationEngineIndex();
                    mAssertion.UIInitialize(mForm, admissibleIndex == -1 ? 0 : admissibleIndex,
                                            verificationEngineIndex == -1 ? 0 : verificationEngineIndex);

                    mAssertion.VerificationOutput.GenerateCounterExample = mListener.generateCounterExample();
                    mAssertion.Action       += mListener.onAction;
                    mAssertion.ReturnResult += VerificationFinished;
                    mAssertion.Cancelled    += Verification_Cancelled;
                    mAssertion.Failed       += MC_Failed;

                    mSeconds = 1;
                    mTimer.Start();
                    mAssertion.Start();
                }
                catch (RuntimeException e)
                {
                    mSpec.UnLockSharedData();
                    Common.Utility.Utilities.LogRuntimeException(e);
                    mListener.updateVerifyBtnLabel(LABEL_VERIFY);
                    mListener.closeForm();
                    return;
                }
                catch (Exception ex)
                {
                    mSpec.UnLockSharedData();
                    Common.Utility.Utilities.LogException(ex, mSpec);
                    mListener.updateVerifyBtnLabel(LABEL_VERIFY);
                    mListener.closeForm();
                    return;
                }
            } while (false);
        }
Example #5
0
        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);
        }
Example #6
0
        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);
        }
Example #7
0
        //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);
        }
        private void StartVerification(bool completed, bool correct)
        {
            FlushString();
            MCTimer.Stop();


            if (AssertionIndex == 0)
            {
                if (completed && FileIndex > 0)
                {
                    if (correct)
                    {
                        ListView_Assertions.Items[FileIndex - 1].ImageIndex = CORRECT_ICON;
                    }
                    else
                    {
                        ListView_Assertions.Items[FileIndex - 1].ImageIndex = WRONG_ICON;
                    }
                }

                if (FileIndex < ListView_Assertions.Items.Count)
                {
                    try
                    {
                        string file = ListView_Assertions.Items[FileIndex].SubItems[2].Text;
                        FileIndex++;

                        this.OutputWriter.WriteLine("*******************************************************");
                        this.OutputWriter.WriteLine("*" + file);
                        this.OutputWriter.WriteLine("**************************START************************");
                        StatusLabel_Text.Text = Resources.Checking_file_ + file;

                        StreamReader tr         = new StreamReader(file);
                        string       specString = tr.ReadToEnd();
                        tr.Close();

                        if (Spec != null)
                        {
                            Spec.UnLockSharedData();
                        }

                        string           modulefolder = Common.Utility.Utilities.ModuleFolderNames[this.ComboBox_Modules.SelectedIndex];
                        ModuleFacadeBase modulebase   = Common.Utility.Utilities.LoadModule(modulefolder);
                        Spec = modulebase.ParseSpecification(specString, "", file);

                        if (Spec != null)
                        {
                            Assertions = new List <string>(Spec.AssertionDatabase.Keys);
                        }
                        else
                        {
                            throw new Exception("ERROR Spec!");
                        }
                    }
                    catch (Exception ex)
                    {
                        if (FileIndex > 0)
                        {
                            ListView_Assertions.Items[FileIndex - 1].ImageIndex = WRONG_ICON;
                        }
                        this.OutputWriter.WriteLine("Error occurred: " + ex.Message + "\r\n" + ex.StackTrace);
                        StartVerification(false, false);
                    }
                }
                else
                {
                    EnableAllControls();
                    return;
                }
            }


            try
            {
                if (Assertions.Count > 0)
                {
                    OutputWriter.WriteLine("=======================================================");
                    OutputWriter.WriteLine("Assertion: " + Assertions[AssertionIndex]);
                    StatusLabel_Text.Text = Resources.Verifying_Assertion__ + Assertions[AssertionIndex];
                    FlushString();

                    Assertion = Spec.AssertionDatabase[Assertions[AssertionIndex]];
                    AssertionIndex++;
                    AssertionIndex = AssertionIndex % Assertions.Count;

                    //Assertion.UIInitialize(this, Fairness, this.CheckBox_PartialOrderReduction.Checked, this.CheckBox_Verbose.Checked, this.CheckBox_Parallel.Checked, this.ShortestPath, this.CheckBox_BDD.Checked, this.CheckBox_CheckNonZenoness.Checked, GetParameters());

                    Assertion.UIInitialize(this, (int)NUD_AdmissibleBehavior.Value, (int)NUD_VerificationEngine.Value);
                    Assertion.VerificationOutput.GenerateCounterExample = CheckBox_GenerateCounterexample.Checked;

                    Assertion.Action       += OnAction;
                    Assertion.ReturnResult += VerificationFinished;
                    Assertion.Cancelled    += Verification_Cancelled;
                    Assertion.Failed       += MC_Failed;

                    seconds           = 1;
                    ProgressBar.Value = 0;
                    //timer.Reset();
                    //startMemroySize = GC.GetTotalMemory(true);
                    MCTimer.Start();
                    //timer.Start();
                    Assertion.Start();
                }
                else
                {
                    StartVerification(true, true);
                }
            }
            catch (RuntimeException e)
            {
                EnableAllControls();
                Common.Utility.Utilities.LogRuntimeException(e);
                this.Close();
                return;
            }
            catch (Exception ex)
            {
                EnableAllControls();
                Common.Utility.Utilities.LogException(ex, Spec);
                this.Close();
                return;
            }
        }
Example #9
0
        private void StartVerification(ListViewItem item)
        {
            if (!ModuleSpecificCheckPassed())
            {
                return;
            }

            if (!Spec.GrabSharedDataLock())
            {
                MessageBox.Show(Resources.Please_wait_for_the_simulation_or_parsing_finished_before_verification, Common.Ultility.Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            DisableAllControls();


            try
            {
                Spec.LockSharedData(false);

                StatusLabel_Text.Text = Resources.ModelCheckingForm_StartVerification_Verification_Starts;

                //these data will not change for SpecProcess.SharedData, so once it is created after parsing, there is no need to set them again.
                //SpecProcess.SharedData.VariableLowerBound = Valuation.VariableLowerBound;
                //SpecProcess.SharedData.VariableUpperLowerBound = Valuation.VariableUpperLowerBound;
                //SpecProcess.SharedData.AlphaDatabase = Specification.AlphaDatabase;
                //SpecProcess.SharedData.HasSyncrhonousChannel = Specification.HasSyncrhonousChannel;
                //SpecProcess.SharedData.SyncrhonousChannelNames = Specification.SyncrhonousChannelNames;


                //SpecProcess.SharedData.FairnessType = AssertionBase.FairnessType;
                //SpecProcess.SharedData.CalculateParticipatingProcess = AssertionBase.FairnessType == FairnessType.PROCESS_LEVEL_WEAK_FAIRNESS || AssertionBase.FairnessType == FairnessType.PROCESS_LEVEL_STRONG_FAIRNESS || Assertion.MustAbstract;
                //SpecProcess.SharedData.CalculateCreatedProcess = Assertion.MustAbstract;
                //SpecProcess.SharedData.DataManager = DataStore.DataManager;


                item.ImageIndex = UNKNOWN_ICON;

                Assertion = Spec.AssertionDatabase[item.SubItems[2].Text];
                Assertion.UIInitialize(this, Fairness, this.CheckBox_PartialOrderReduction.Checked, this.CheckBox_Verbose.Checked, this.CheckBox_Parallel.Checked, this.ShortestPath, this.CheckBox_BDD.Checked, this.CheckBox_CheckNonZenoness.Checked, GetParameters());


                Assertion.Action       += OnAction;
                Assertion.ReturnResult += VerificationFinished;
                Assertion.Cancelled    += Verification_Cancelled;
                Assertion.Failed       += MC_Failed;

                seconds           = 1;
                ProgressBar.Value = 0;
                //timer.Reset();
                //startMemroySize = GC.GetTotalMemory(true);
                MCTimer.Start();
                //timer.Start();
                Assertion.Start();
            }
            catch (RuntimeException e)
            {
                Common.Ultility.Ultility.LogRuntimeException(e);
                this.Close();
                return;
            }
            catch (Exception ex)
            {
                //TextBox_Output.Text += ex.Message + "\r\n" + ex.StackTrace;
                //EnableAllControls();
                Common.Ultility.Ultility.LogException(ex, Spec);
                this.Close();
                return;
            }
        }