IEnumerable <ITestContext> ITestContextsProviderAttribute.GetContexts(MethodInfo testMethod)
        {
            var contextAttributes = (ChessTestContextAttribute[])testMethod.GetCustomAttributes(typeof(ChessTestContextAttribute), true);

            // Create the initial options as provided by this attribute
            MChessOptions baseOptions = new MChessOptions()
            {
                //IncludedAssemblies = ChessInstrumentAssemblyAttribute.GetAssembliesToInstrument(testMethod)
            };

            foreach (var ctxAttr in contextAttributes)
            {
                // Copy the settings from the attribute over to the options
                MChessOptions opts = baseOptions.Clone();
                opts.MergeWith(ctxAttr);

                yield return(new ChessTestContext(ctxAttr.Name
                                                  , ctxAttr.ExpectedResultKey
                                                  , ctxAttr.ExpectedChessResultKey
                                                  , opts
                                                  )
                {
                    PreRunScript = ctxAttr.PreRunScript
                });
            }
        }
Exemplo n.º 2
0
        private ChessTestContext CreateTestContext()
        {
            var envVars = MyEngine.EnvironmentVars;

            var opts = new Microsoft.Concurrency.TestTools.UnitTesting.Chess.MChessOptions()
            {
                // There isn't any way to get these options just passed straight thru
                //EnableAtomicityChecking = envVars.
                //EnableRaceDetection = envVars.,
                PreemptAllAccesses = envVars.PreemptAccesses,

                MaxChessTime   = envVars.MaxChessTime,
                MaxPreemptions = envVars.MaxPreemptions,
                MaxExecs       = envVars.MaxExecs,
                MaxExecSteps   = envVars.MaxExecSteps,
                MaxExecTime    = envVars.MaxExecTime,
                ProcessorCount = envVars.ProcessorCount,

                IncludedAssemblies    = envVars.IncludeAssemblies.ToArray(),
                FlipPreemptionSense   = envVars.FlipPreemptSense,
                DontPreemptAssemblies = envVars.DontPreemptAssemblies.ToArray(),
                DontPreemptNamespaces = envVars.DontPreemptNamespaces.ToArray(),
                DontPreemptTypes      = envVars.DontPreemptTypes.ToArray(),
                DontPreemptMethods    = envVars.DontPreemptMethods.ToArray(),
            };

            return(new ChessTestContext(null, null, null, opts));
        }
Exemplo n.º 3
0
        /// <summary>Creates a copy of all the options set on this instance.</summary>
        public MChessOptions Clone()
        {
            MChessOptions copy = new MChessOptions()
            {
                // ChessTestContextAttributeable
                MaxChessTime   = this.MaxChessTime,
                MaxPreemptions = this.MaxPreemptions,
                MaxExecs       = this.MaxExecs,
                MaxExecSteps   = this.MaxExecSteps,
                MaxExecTime    = this.MaxExecTime,
                ProcessorCount = this.ProcessorCount,

                // Non-context properties
                EnableRaceDetection       = this.EnableRaceDetection,
                EnableAtomicityChecking   = this.EnableAtomicityChecking,
                EnableDeterminismChecking = this.EnableDeterminismChecking,
                PreemptVolatiles          = this.PreemptVolatiles,
                PreemptAllAccesses        = this.PreemptAllAccesses,

                Break             = this.Break,
                EnableRepro       = this.EnableRepro,
                EnableTracing     = this.EnableTracing,
                TraceAllSchedules = this.TraceAllSchedules,
                TargetRace        = this.TargetRace,
                XSchedule         = this.XSchedule,
                ScheduleFilePath  = this.ScheduleFilePath,

                EnumerateObservations = this.EnumerateObservations,
                CheckObservations     = this.CheckObservations,
                ObservationMode       = this.ObservationMode,
                ObservationFile       = this.ObservationFile,

                ContinueFromLastSchedule = this.ContinueFromLastSchedule,

                IncludedAssemblies = this.IncludedAssemblies == null ? null : (string[])this.IncludedAssemblies.Clone(),

                FlipPreemptionSense   = this.FlipPreemptionSense,
                DontPreemptAssemblies = this.DontPreemptAssemblies == null ? null : (string[])this.DontPreemptAssemblies.Clone(),
                DontPreemptNamespaces = this.DontPreemptNamespaces == null ? null : (string[])this.DontPreemptNamespaces.Clone(),
                DontPreemptTypes      = this.DontPreemptTypes == null ? null : (string[])this.DontPreemptTypes.Clone(),
                DontPreemptMethods    = this.DontPreemptMethods == null ? null : (string[])this.DontPreemptMethods.Clone(),

                ExtraCommandLineArgs = this.ExtraCommandLineArgs == null ? null : (string[])this.ExtraCommandLineArgs.Clone(),

                EnableLogging = this.EnableLogging,
                PrintDiagnosticInformation = this.PrintDiagnosticInformation,

                ShowHBExecs = this.ShowHBExecs,
                NoPopups    = this.NoPopups,
                NoTime      = this.NoTime,
            };

            return(copy);
        }
Exemplo n.º 4
0
 public ChessTestContext(string name, string expResultKey, string expChessResultKey, MChessOptions options)
     : base(name, expResultKey)
 {
     ExpectedChessResultKey = expChessResultKey;
     Options = options;
 }
Exemplo n.º 5
0
        /// <summary>Merges in the specified options from other into this instance.</summary>
        /// <param name="other">may be null.</param>
        public void MergeWith(MChessOptions other)
        {
            if (other == null)
            {
                return;
            }

            // Contextable
            if (other.MaxChessTime.HasValue)
            {
                this.MaxChessTime = other.MaxChessTime;
            }
            if (other.MaxPreemptions.HasValue)
            {
                this.MaxPreemptions = other.MaxPreemptions;
            }
            if (other.MaxExecs.HasValue)
            {
                this.MaxExecs = other.MaxExecs;
            }
            if (other.MaxExecSteps.HasValue)
            {
                this.MaxExecSteps = other.MaxExecSteps;
            }
            if (other.MaxExecTime.HasValue)
            {
                this.MaxExecTime = other.MaxExecTime;
            }
            if (other.ProcessorCount.HasValue)
            {
                this.ProcessorCount = other.ProcessorCount;
            }
            if (other.EnableRaceDetection.HasValue)
            {
                this.EnableRaceDetection = other.EnableRaceDetection;
            }
            if (other.EnableAtomicityChecking.HasValue)
            {
                this.EnableAtomicityChecking = other.EnableAtomicityChecking;
            }
            if (other.EnableDeterminismChecking.HasValue)
            {
                this.EnableDeterminismChecking = other.EnableDeterminismChecking;
            }
            if (other.PreemptVolatiles.HasValue)
            {
                this.PreemptVolatiles = other.PreemptVolatiles;
            }
            if (other.PreemptAllAccesses.HasValue)
            {
                this.PreemptAllAccesses = other.PreemptAllAccesses;
            }

            // All others
            if (other.Break.HasValue)
            {
                this.Break = other.Break;
            }
            if (other.EnableLogging.HasValue)
            {
                this.EnableLogging = other.EnableLogging;
            }
            if (other.EnableRepro.HasValue)
            {
                this.EnableRepro = other.EnableRepro;
            }
            if (other.EnableTracing.HasValue)
            {
                this.EnableTracing = other.EnableTracing;
            }
            if (other.TraceAllSchedules.HasValue)
            {
                this.TraceAllSchedules = other.TraceAllSchedules;
            }
            if (other.TargetRace.HasValue)
            {
                this.TargetRace = other.TargetRace;
            }
            if (other.XSchedule != null)
            {
                this.XSchedule = other.XSchedule;
            }
            if (!String.IsNullOrEmpty(other.ScheduleFilePath))
            {
                this.ScheduleFilePath = other.ScheduleFilePath;
            }

            if (other.EnumerateObservations.HasValue)
            {
                this.EnumerateObservations = other.EnumerateObservations;
            }
            if (other.CheckObservations.HasValue)
            {
                this.CheckObservations = other.CheckObservations;
            }
            if (other.ObservationMode.HasValue)
            {
                this.ObservationMode = other.ObservationMode;
            }
            if (other.ObservationFile != null)
            {
                this.ObservationFile = other.ObservationFile;
            }

            this.ContinueFromLastSchedule = other.ContinueFromLastSchedule;

            // Merge assemblies
            if (other.IncludedAssemblies != null)
            {
                this.IncludedAssemblies = MergeStringArrays(this.IncludedAssemblies, other.IncludedAssemblies);
            }

            // Merge preemption settings
            if (other.FlipPreemptionSense.HasValue)
            {
                this.FlipPreemptionSense = other.FlipPreemptionSense;
            }
            if (other.DontPreemptAssemblies != null)
            {
                this.DontPreemptAssemblies = MergeStringArrays(this.DontPreemptAssemblies, other.DontPreemptAssemblies);
            }
            if (other.DontPreemptNamespaces != null)
            {
                this.DontPreemptNamespaces = MergeStringArrays(this.DontPreemptNamespaces, other.DontPreemptNamespaces);
            }
            if (other.DontPreemptTypes != null)
            {
                this.DontPreemptTypes = MergeStringArrays(this.DontPreemptTypes, other.DontPreemptTypes);
            }
            if (other.DontPreemptMethods != null)
            {
                this.DontPreemptMethods = MergeStringArrays(this.DontPreemptMethods, other.DontPreemptMethods);
            }

            // Merge extra command line args
            if (other.ExtraCommandLineArgs != null)
            {
                this.ExtraCommandLineArgs = ConcatStringArrays(this.ExtraCommandLineArgs, other.ExtraCommandLineArgs);
            }

            if (other.EnableLogging.HasValue)
            {
                this.EnableLogging = other.EnableLogging;
            }
            if (other.PrintDiagnosticInformation.HasValue)
            {
                this.PrintDiagnosticInformation = other.PrintDiagnosticInformation;
            }

            if (other.ShowHBExecs.HasValue)
            {
                this.ShowHBExecs = other.ShowHBExecs;
            }
            if (other.NoPopups.HasValue)
            {
                this.NoPopups = other.NoPopups;
            }
            if (other.NoTime.HasValue)
            {
                this.NoTime = other.NoTime;
            }
        }