Ejemplo 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();
            }
        }
Ejemplo n.º 2
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();
            //}
        }
 public string Report()
 {
     return(m_engine.Report());
 }