/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> /// <param name="trace">ScheduleTrace</param> public ReplayStrategy(Configuration configuration, ScheduleTrace trace) { this.Configuration = configuration; this.ScheduleTrace = trace; this.MaxExploredSteps = 0; this.ExploredSteps = 0; }
/// <summary> /// Creates arguments from the specified configuration. /// </summary> /// <param name="id">Unique process id</param> /// <param name="configuration">Configuration</param> /// <returns>Arguments</returns> private static string CreateArgumentsFromConfiguration(int id, Configuration configuration) { StringBuilder arguments = new StringBuilder(); if (configuration.EnableDebugging) { arguments.Append($"/debug "); } arguments.Append($"/test:{configuration.AssemblyToBeAnalyzed} "); arguments.Append($"/i:{configuration.SchedulingIterations} "); arguments.Append($"/timeout:{configuration.Timeout} "); arguments.Append($"/max-steps:{configuration.MaxSchedulingSteps} "); if (configuration.SchedulingStrategy == SchedulingStrategy.PCT) { arguments.Append($"/sch:{configuration.SchedulingStrategy}:" + $"{configuration.PrioritySwitchBound} "); } else if (configuration.SchedulingStrategy == SchedulingStrategy.Random || configuration.SchedulingStrategy == SchedulingStrategy.Portfolio) { arguments.Append($"/sch:{configuration.SchedulingStrategy} "); } arguments.Append($"/parallel:{configuration.ParallelBugFindingTasks} "); arguments.Append($"/testing-scheduler-process-id:{Process.GetCurrentProcess().Id} "); arguments.Append($"/testing-process-id:{id}"); return arguments.ToString(); }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> private CompilationContext(Configuration configuration) { this.Configuration = configuration; this.PSharpProjects = new List<PSharpProject>(); this.CustomCompilerPassAssemblies = new HashSet<Assembly>(); this.LoadCustomCompilerPasses(); }
/// <summary> /// Constructor. /// </summary> /// <param name="testingEngine">ITestingEngine</param> /// <param name="configuration">Configuration</param> public RaceInstrumentationEngine(ITestingEngine testingEngine, Configuration configuration) : base(new Container(), new EngineOptions(), new MonitorManager(testingEngine, configuration), new ThreadMonitorManager(configuration)) { if (SingletonEngine != null) { throw new InvalidOperationException("RaceInstrumentationEngine created more than once."); } SingletonEngine = this; // required? AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomainProcessExit); this.GetService<ISymbolManager>().AddStackFrameFilter(new StackFrameFilter()); if (!ControllerEnvironment.IsMonitoringEnabled) { Console.WriteLine("ExtendedReflection monitor not enabled"); throw new NotImplementedException("ExtendedReflection monitor not enabled"); } ((IMonitorManager)this.GetService<MonitorManager>()).RegisterThreadMonitor( new ThreadMonitorFactory(this.GetService<ThreadMonitorManager>(), testingEngine, configuration)); ((IMonitorManager)this.GetService<MonitorManager>()).RegisterObjectAccessThreadMonitor(); this.ExecutionMonitor.Initialize(); var tid = this.ExecutionMonitor.CreateThread(); _ThreadContext.Start(this.ExecutionMonitor, tid); }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> /// <param name="delays">Max number of delays</param> public RandomDelayBoundingStrategy(Configuration configuration, int delays) : base(configuration, delays) { this.Seed = this.Configuration.RandomSchedulingSeed ?? DateTime.Now.Millisecond; this.Random = new Random(this.Seed); this.CurrentIterationDelays = new List<int>(); }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> public InteractiveStrategy(Configuration configuration) { this.Configuration = configuration; this.InputCache = new List<string>(); this.ExploredSteps = 0; this.PrioritizedOperationId = 0; }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> public RandomStrategy(Configuration configuration) { this.Configuration = configuration; this.Seed = this.Configuration.RandomSchedulingSeed ?? DateTime.Now.Millisecond; this.Random = new Random(this.Seed); this.ExploredSteps = 0; }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> public MaceMCStrategy(Configuration configuration) { this.Configuration = configuration; this.SafetyPrefixDepth = this.Configuration.SafetyPrefixBound; this.BoundedDFS = new IterativeDeepeningDFSStrategy(configuration); this.Random = new RandomStrategy(configuration); }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> public RaceDetectionEngine(Configuration configuration) { this.Configuration = configuration; this.AllThreadTraces = new List<ThreadTrace>(); this.CGraph = new BidirectionalGraph<Node, Edge>(); }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> /// <param name="numberOfCoinFlips">Number of coin flips</param> public ProbabilisticRandomStrategy(Configuration configuration, int numberOfCoinFlips) { this.Configuration = configuration; this.Seed = this.Configuration.RandomSchedulingSeed ?? DateTime.Now.Millisecond; this.Random = new Random(this.Seed); this.NumberOfCoinFlips = numberOfCoinFlips; this.ExploredSteps = 0; }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> /// <param name="delays">Max number of delays</param> public DelayBoundingStrategy(Configuration configuration, int delays) { this.Configuration = configuration; this.MaxExploredSteps = 0; this.ExploredSteps = 0; this.MaxDelays = delays; this.RemainingDelays = new List<int>(); }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> public ThreadMonitorManager(Configuration configuration) : base() { this.Configuration = configuration; this.MonitorFactories = new SafeList<IThreadMonitorFactory>(); this.ThreadExecutionMonitors = new SafeList<ThreadExecutionMonitorMultiplexer>(); this.DestroyedExecutionMonitorIds = new SafeQueue<int>(); }
/// <summary> /// Constructor. /// </summary> /// <param name="host">ICopComponent</param> /// <param name="configuration">Configuration</param> public ThreadMonitorFactory(ICopComponent host, ITestingEngine testingEngine, Configuration configuration) : base(host) { this.Configuration = configuration; this.TestingEngine = testingEngine; this.ThreadMonitors = new ThreadMonitorCollection(); }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> public OperationBoundingStrategy(Configuration configuration) { this.Configuration = configuration; this.Operations = new List<int>(); this.Seed = this.Configuration.RandomSchedulingSeed ?? DateTime.Now.Millisecond; this.Random = new Random(this.Seed); this.MaxExploredSteps = 0; this.ExploredSteps = 0; }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> public DFSStrategy(Configuration configuration) { this.Configuration = configuration; this.ScheduleStack = new List<List<SChoice>>(); this.BoolNondetStack = new List<List<NondetBooleanChoice>>(); this.IntNondetStack = new List<List<NondetIntegerChoice>>(); this.SchIndex = 0; this.NondetIndex = 0; this.ExploredSteps = 0; }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> /// <param name="delays">Max number of delays</param> public DelayBoundingStrategy(Configuration configuration, int delays) { this.Configuration = configuration; this.Seed = this.Configuration.RandomSchedulingSeed ?? DateTime.Now.Millisecond; this.Random = new Random(this.Seed); this.MaxExploredSteps = 0; this.ExploredSteps = 0; this.MaxDelays = delays; this.RemainingDelays = new List<int>(); }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> public DFSStrategy(Configuration configuration) { this.Configuration = configuration; this.ScheduleStack = new List<List<SChoice>>(); this.NondetStack = new List<List<NondetChoice>>(); this.SchIndex = 0; this.NondetIndex = 0; this.MaxExploredSteps = 0; this.ExploredSteps = 0; }
/// <summary> /// Configures the container. /// </summary> /// <param name="configuration">Configuration</param> internal static void Configure(Configuration configuration) { Container.Configuration = configuration; Output.PrettyPrintLine(". Setting up"); Container.LoadApplicationAssembly(); Container.RegisterSerializableTypes(); Output.PrettyPrintLine("... Configured as container '{0}'", Configuration.ContainerId); }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> /// <param name="depth">Bug depth</param> public PCTStrategy(Configuration configuration, int depth) { this.Configuration = configuration; this.MaxExploredSteps = 0; this.ExploredSteps = 0; this.BugDepth = depth; this.Seed = this.Configuration.RandomSchedulingSeed ?? DateTime.Now.Millisecond; this.Random = new Random(this.Seed); this.PrioritizedMachines = new List<MachineId>(); this.PriorityChangePoints = new SortedSet<int>(); }
/// <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(); }
/// <summary> /// Creates a new P# testing process. /// </summary> /// <param name="id">Unique process id</param> /// <param name="configuration">Configuration</param> /// <returns>Process</returns> public static Process Create(int id, Configuration configuration) { ProcessStartInfo startInfo = new ProcessStartInfo( Assembly.GetExecutingAssembly().Location, CreateArgumentsFromConfiguration(id, configuration)); startInfo.UseShellExecute = false; Process process = new Process(); process.StartInfo = startInfo; return process; }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> private TestingProcess(Configuration configuration) { if (configuration.ParallelBugFindingTasks > 1 && configuration.SchedulingStrategy == SchedulingStrategy.Portfolio) { TestingPortfolio.ConfigureStrategyForCurrentProcess(configuration); } this.Configuration = configuration; this.TestingEngine = TestingEngineFactory.CreateBugFindingEngine( this.Configuration); }
/// <summary> /// Configures the container. /// </summary> /// <param name="configuration">Configuration</param> internal static void Configure(Configuration configuration) { configuration.PauseOnAssertionFailure = true; Container.Configuration = configuration; IO.PrettyPrintLine(". Setting up the runtime container"); Container.LoadApplicationAssembly(); Container.RegisterSerializableTypes(); IO.PrettyPrintLine("... Configured as container '{0}'", Configuration.ContainerId); }
/// <summary> /// Configures the testing strategy for the current /// testing process. /// </summary> /// <param name="configuration">Configuration</param> internal static void ConfigureStrategyForCurrentProcess( Configuration configuration) { if (configuration.TestingProcessId % 2 == 0) { configuration.SchedulingStrategy = SchedulingStrategy.Random; } else { configuration.SchedulingStrategy = SchedulingStrategy.PCT; configuration.PrioritySwitchBound = configuration.TestingProcessId; } }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> private TestingProcessScheduler(Configuration configuration) { this.TestingProcesses = new Dictionary<int, Process>(); this.Profiler = new Profiler(); this.SchedulerLock = new object(); this.BugFound = false; configuration.Verbose = 1; configuration.PrintTrace = false; configuration.PerformFullExploration = false; configuration.EnableDataRaceDetection = false; this.Configuration = configuration; }
/// <summary> /// Creates a new P# replaying engine. /// </summary> /// <param name="configuration">Configuration</param> /// <param name="action">Action</param> /// <returns>ReplayEngine</returns> public static ReplayEngine Create(Configuration configuration, Action<PSharpRuntime> action) { return new ReplayEngine(configuration, action); }
/// <summary> /// Creates a new P# replaying engine. /// </summary> /// <param name="configuration">Configuration</param> /// <param name="assembly">Assembly</param> /// <returns>ReplayEngine</returns> public static ReplayEngine Create(Configuration configuration, Assembly assembly) { return new ReplayEngine(configuration, assembly); }
/// <summary> /// Creates a new P# replaying engine. /// </summary> /// <param name="configuration">Configuration</param> /// <returns>ReplayEngine</returns> public static ReplayEngine Create(Configuration configuration) { return new ReplayEngine(configuration); }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> /// <param name="action">Action</param> private ReplayEngine(Configuration configuration, Action<PSharpRuntime> action) : base(configuration, action) { }
/// <summary> /// Constructor. /// </summary> /// <param name="configuration">Configuration</param> /// <param name="assembly">Assembly</param> private ReplayEngine(Configuration configuration, Assembly assembly) : base(configuration, assembly) { }
/// <summary> /// Constructor. /// </summary> /// <param name="args">Array of arguments</param> public BaseCommandLineOptions(string[] args) { this.Configuration = Configuration.Create(); this.Options = args; }