Esempio n. 1
0
        /// <summary>
        /// Invokes the P# testing engine.
        /// </summary>
        /// <param name="configuration">Configuration</param>
        public void Execute(Configuration configuration)
        {
            // Creates and runs the P# testing engine to find bugs in the P# program.
            ITestingEngine testingEngine = TestingEngineFactory.CreateBugFindingEngine(configuration);

            var assembly = Assembly.LoadFrom(configuration.AssemblyToBeAnalyzed);

            new RaceInstrumentationEngine(testingEngine, configuration);

            this.TryLoadReferencedAssemblies(new[] { assembly });

            testingEngine.Run();

            IO.Error.PrintLine(testingEngine.Report());
            if (testingEngine.TestReport.NumOfFoundBugs > 0 ||
                configuration.PrintTrace)
            {
                testingEngine.TryEmitTraces();
            }

            if (configuration.ReportCodeCoverage)
            {
                testingEngine.TryEmitCoverageReport();
            }
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            // Optional: increases verbosity level to see the P# runtime log.
            Configuration configuration = Configuration.Create();

            configuration.SchedulingIterations = 10;
            ITestingEngine engine = TestingEngineFactory.CreateBugFindingEngine(configuration, DefaultImpl.Execute);

            engine.Run();
            string bug = engine.TestReport.BugReports.FirstOrDefault();

            if (bug != null)
            {
                Console.WriteLine(bug);
            }

            /*
             * // Creates a new P# runtime instance, and passes an optional configuration.
             * var runtime = PSharpRuntime.Create(configuration);
             *
             * // Executes the P# program.
             * DefaultImpl.Execute(runtime);
             *
             * // The P# runtime executes asynchronously, so we wait
             * // to not terminate the process.
             * Console.WriteLine("Press Enter to terminate...");
             */
        }
Esempio n. 3
0
        public static ITestingEngine RunAndEmitTraces(this ITestingEngine @this, TestArtifact testArtifact)
        {
            var engine = @this.Run();

            @this.TryEmitTraces(testArtifact.Directory, testArtifact.TraceNameBase);
            return(@this);
        }
Esempio n. 4
0
        /// <summary>
        /// Starts the P# replaying process.
        /// </summary>
        public void Start()
        {
            Output.WriteLine(". Reproducing trace in " + this.Configuration.AssemblyToBeAnalyzed);

            // Creates a new P# replay engine to reproduce a bug.
            ITestingEngine engine = TestingEngineFactory.CreateReplayEngine(this.Configuration);

            engine.Run();
            Output.WriteLine(engine.Report());
        }
        /// <summary>
        /// Invokes the P# testing engine.
        /// </summary>
        /// <param name="configuration">Configuration</param>
        public void Execute(Configuration configuration)
        {
            // Creates and runs the P# testing engine to find bugs in the P# program.
            ITestingEngine testingEngine = TestingEngineFactory.CreateBugFindingEngine(configuration);

            var assembly = Assembly.LoadFrom(configuration.AssemblyToBeAnalyzed);

            new RaceInstrumentationEngine(testingEngine.Reporter, configuration);

            this.TryLoadReferencedAssemblies(new[] { assembly });

            testingEngine.Run();

            Output.WriteLine(testingEngine.Report());
            if (testingEngine.TestReport.NumOfFoundBugs > 0)
            {
                string file = Path.GetFileNameWithoutExtension(configuration.AssemblyToBeAnalyzed);
                file += "_" + configuration.TestingProcessId;

                string directoryPath;
                string suffix = "";

                if (configuration.OutputFilePath != "")
                {
                    directoryPath = configuration.OutputFilePath + Path.DirectorySeparatorChar;
                }
                else
                {
                    var subpath = Path.GetDirectoryName(configuration.AssemblyToBeAnalyzed);
                    if (subpath == "")
                    {
                        subpath = ".";
                    }

                    directoryPath = subpath +
                                    Path.DirectorySeparatorChar + "Output" + Path.DirectorySeparatorChar;
                }

                if (suffix.Length > 0)
                {
                    directoryPath += suffix + Path.DirectorySeparatorChar;
                }

                Directory.CreateDirectory(directoryPath);
                Output.WriteLine($"... Emitting task {configuration.TestingProcessId} traces:");
                testingEngine.TryEmitTraces(directoryPath, file);
            }

            //if (configuration.ReportCodeCoverage)
            //{
            //    testingEngine.TryEmitCoverageReport();
            //}
        }
        /// <summary>
        /// Invokes the P# testing engine.
        /// </summary>
        /// <param name="configuration">Configuration</param>
        public void Execute(Configuration configuration)
        {
            // Creates and runs the P# testing engine to find bugs in the P# program.
            ITestingEngine testingEngine = TestingEngineFactory.CreateBugFindingEngine(configuration);

            var assembly = Assembly.LoadFrom(configuration.AssemblyToBeAnalyzed);

            new RaceInstrumentationEngine(testingEngine, configuration);

            this.TryLoadReferencedAssemblies(new[] { assembly });

            testingEngine.Run();
        }
Esempio n. 7
0
        public static void Main(string[] args)
        {
            // Optional: increases verbosity level to see the Coyote runtime log.
            Configuration configuration = Configuration.Create();

            configuration.SchedulingIterations = 10;
            ITestingEngine engine = TestingEngineFactory.CreateBugFindingEngine(configuration, DefaultImpl.Execute);

            engine.Run();
            string bug = engine.TestReport.BugReports.FirstOrDefault();

            if (bug != null)
            {
                Console.WriteLine(bug);
            }
        }
 public ITestingEngine Run()
 {
     m_engine.Run();
     return(this);
 }