static Interceptor() { var workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); Directory.SetCurrentDirectory(workingDirectory); string configPath = Path.Combine(workingDirectory, Constants.RuntimeConfigFile); Configuration = TSVDRuntimeConfiguration.Parse(configPath); }
/// <summary> /// Parse config. /// </summary> /// <param name="filePath">Config file path.</param> /// <returns>Parsed config object.</returns> public static TSVDRuntimeConfiguration Parse(string filePath) { XmlSerializer serializer = new XmlSerializer(typeof(TSVDRuntimeConfiguration)); XmlReaderSettings settings = new XmlReaderSettings(); using (var reader = XmlReader.Create(filePath, settings)) { TSVDRuntimeConfiguration config = serializer.Deserialize(reader) as TSVDRuntimeConfiguration; config.Initialize(); return(config); } }
/// <summary> /// Read thread safety specification files. /// </summary> /// <param name="threadSafetySpecificationFiles">Thread safety specification files.</param> /// <returns>Thread safety groups.</returns> public static List <ThreadSafetyGroup> ReadThreadSafetyGroups(List <string> threadSafetySpecificationFiles) { List <ThreadSafetyGroup> threadSafetyGroups = new List <ThreadSafetyGroup>(); foreach (string filePath in threadSafetySpecificationFiles) { string exePath = Assembly.GetExecutingAssembly().Location; string fullPath = Path.Combine(Path.GetDirectoryName(exePath), filePath); TSVDRuntimeConfiguration threadSafetySpecification = TSVDRuntimeConfiguration.Parse(fullPath); threadSafetyGroups.AddRange(threadSafetySpecification.ThreadSafetyGroups); } return(threadSafetyGroups); }
/// <inheritdoc/> public void Initialize(TSVDRuntimeConfiguration configuration) { this.configuration = configuration; this.trapPoints = new Dictionary <string, Dictionary <Guid, Trap> >(); this.writeTrapPoints = new HashSet <string>(); if (this.configuration.BugLogPath != null) { this.bugLogger = new FileLogger(LogHelper.GetFilePathWithExecutionId(this.configuration.BugLogPath)); } this.isTrapActive = false; int seed = this.RandomSeed != 0 ? this.RandomSeed : Guid.NewGuid().GetHashCode(); this.random = new Random(seed); ControllerHelper.Debug(string.Format("RandomSeed: {0}", seed)); }
/// <summary> /// Initialize the controller. /// </summary> /// <param name="configuration">The configuration.</param> /// <inheritdoc /> public void Initialize(TSVDRuntimeConfiguration configuration) { this.configuration = configuration; if (this.LogDirectory != null && Directory.Exists(this.LogDirectory)) { ControllerHelper.SetLoggingDirectory(this.LogDirectory); this.LastRunPlanFile = Path.Combine(this.LogDirectory, Path.GetFileName(this.LastRunPlanFile)); this.LastRunBugFile = Path.Combine(this.LogDirectory, Path.GetFileName(this.LastRunBugFile)); } if (this.configuration.BugLogPath != null) { this.bugLogger = new FileLogger(LogHelper.GetFilePathWithExecutionId(this.configuration.BugLogPath)); } this.isTrapActive = false; int seed = this.RandomSeed != 0 ? this.RandomSeed : Guid.NewGuid().GetHashCode(); this.random = new Random(seed); ControllerHelper.Debug(string.Format("RandomSeed: {0}", seed)); if (this.LastRunPlanFile != null) { if (File.Exists(this.LastRunPlanFile)) { this.LoadPlansFromLastRun(this.LastRunPlanFile); File.Delete(this.LastRunPlanFile); } this.lastRunPlanLogger = new FileLogger(this.LastRunPlanFile); } if (this.LastRunBugFile != null) { if (File.Exists(this.LastRunBugFile)) { this.LoadKnownBuggyInterceptionPoints(this.LastRunBugFile); } this.lastRunBugLogger = new FileLogger(this.LastRunBugFile); } }