/// <summary>
        /// Initializes a new instance of the <see cref="OperationScheduler"/> class.
        /// </summary>
        private OperationScheduler(Configuration configuration)
        {
            this.Configuration    = configuration;
            this.SchedulingPolicy = configuration.IsConcurrencyFuzzingEnabled ?
                                    SchedulingPolicy.Fuzzing : SchedulingPolicy.Systematic;

            this.ValueGenerator = new RandomValueGenerator(configuration);

            if (!configuration.UserExplicitlySetLivenessTemperatureThreshold &&
                configuration.MaxFairSchedulingSteps > 0)
            {
                configuration.LivenessTemperatureThreshold = configuration.MaxFairSchedulingSteps / 2;
            }

            if (this.SchedulingPolicy is SchedulingPolicy.Systematic)
            {
                this.Strategy = SystematicStrategy.Create(configuration, this.ValueGenerator);
                if (this.Strategy is ReplayStrategy replayStrategy)
                {
                    this.ReplayStrategy      = replayStrategy;
                    this.IsReplayingSchedule = true;
                }
            }
            else if (this.SchedulingPolicy is SchedulingPolicy.Fuzzing)
            {
                this.Strategy = FuzzingStrategy.Create(configuration, this.ValueGenerator);
            }
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OperationScheduler"/> class.
        /// </summary>
        private OperationScheduler(SchedulingPolicy policy, IRandomValueGenerator valueGenerator, Configuration configuration)
        {
            this.Configuration    = configuration;
            this.SchedulingPolicy = policy;
            this.ValueGenerator   = valueGenerator;

            if (!configuration.UserExplicitlySetLivenessTemperatureThreshold &&
                configuration.MaxFairSchedulingSteps > 0)
            {
                configuration.LivenessTemperatureThreshold = configuration.MaxFairSchedulingSteps / 2;
            }

            if (this.SchedulingPolicy is SchedulingPolicy.Systematic)
            {
                this.Strategy = SystematicStrategy.Create(configuration, this.ValueGenerator);
                if (this.Strategy is ReplayStrategy replayStrategy)
                {
                    this.ReplayStrategy      = replayStrategy;
                    this.IsReplayingSchedule = true;
                }

                // Wrap the strategy inside a liveness checking strategy.
                if (this.Configuration.IsLivenessCheckingEnabled)
                {
                    this.Strategy = new TemperatureCheckingStrategy(this.Configuration, this.Strategy as SystematicStrategy);
                }
            }
            else if (this.SchedulingPolicy is SchedulingPolicy.Fuzzing)
            {
                this.Strategy = FuzzingStrategy.Create(configuration, this.ValueGenerator);
            }
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OperationScheduler"/> class.
        /// </summary>
        private OperationScheduler(Configuration configuration, SchedulingPolicy policy, IRandomValueGenerator generator)
        {
            this.Configuration    = configuration;
            this.SchedulingPolicy = policy;
            this.ValueGenerator   = generator;

            this.Reducers = new List <IScheduleReducer>();
            if (configuration.IsSharedStateReductionEnabled)
            {
                this.Reducers.Add(new SharedStateReducer());
            }

            if (!configuration.UserExplicitlySetLivenessTemperatureThreshold &&
                configuration.MaxFairSchedulingSteps > 0)
            {
                configuration.LivenessTemperatureThreshold = configuration.MaxFairSchedulingSteps / 2;
            }

            if (this.SchedulingPolicy is SchedulingPolicy.Interleaving)
            {
                this.Strategy = InterleavingStrategy.Create(configuration, generator);
                if (this.Strategy is ReplayStrategy replayStrategy)
                {
                    this.ReplayStrategy      = replayStrategy;
                    this.IsReplayingSchedule = true;
                }

                // Wrap the strategy inside a liveness checking strategy.
                if (configuration.IsLivenessCheckingEnabled)
                {
                    this.Strategy = new TemperatureCheckingStrategy(configuration, generator,
                                                                    this.Strategy as InterleavingStrategy);
                }
            }
            else if (this.SchedulingPolicy is SchedulingPolicy.Fuzzing)
            {
                this.Strategy = FuzzingStrategy.Create(configuration, generator);
            }
        }
 // To be used when RelaxedConcurrencyTesting is enabled.
 public void SetSchedulerStrategyToDelayFuzzing()
 {
     this.SchedulingPolicy = SchedulingPolicy.Fuzzing;
     this.Strategy         = FuzzingStrategy.Create(this.Configuration, this.ValueGenerator);
 }