示例#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();
            }
        }
示例#2
0
        public static ITestingEngine RunAndEmitTraces(this ITestingEngine @this, TestArtifact testArtifact)
        {
            var engine = @this.Run();

            @this.TryEmitTraces(testArtifact.Directory, testArtifact.TraceNameBase);
            return(@this);
        }
        /// <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 void TryEmitTraces(string directory, string file)
 {
     m_engine.TryEmitTraces(directory, file);
 }