static int Main(string[] args) { if (!Parser.ParseArgumentsWithUsage(args, _cmdLine)) { return(ExitCodeError); } if (_cmdLine.Logs.Length != 2) { Console.Error.WriteLine("Can compare 2 logs but specified {0}", _cmdLine.Logs.Length); return(ExitCodeError); } int count = int.MaxValue; if (_cmdLine.count != null) { if (_cmdLine.count == "min") { count = -1; } else { count = int.Parse(_cmdLine.count); } } string hint; bool result; try { result = GameLogComparer.Compare(_cmdLine.Logs[0], _cmdLine.Logs[1], out hint, count); } catch (Exception e) { Console.Error.WriteLine(e.ToString()); return(ExitCodeError); } Console.WriteLine(hint); return(result ? ExitCodeEqual : ExitCodeUnequal); }
// Naming convention: // Log file : baseName.log // Zipped log file: baseName.zip // Session suite : baseName-ss.xml void Replay(string baseName) { string testResourcesPath = UTHelper.GetTestResourceDir(Assembly.GetExecutingAssembly()); string tempDir = Path.GetTempPath(); string configZip = Path.Combine(testResourcesPath, baseName + ".zip"); FastZip fz = new FastZip(); fz.ExtractZip(configZip, tempDir, FastZip.Overwrite.Always, null, "", "", true); string origLogPath = Path.Combine(tempDir, baseName + ".log"); string ssConfigFile = Path.Combine(testResourcesPath, baseName + "-ss.xml"); _ssRunner = new SessionSuiteRunner(); _ssRunner.Configuration = XmlSerializerExt.Deserialize <SessionSuiteCfg>(ssConfigFile); _ssRunner.IsLoggingEnabled = true; _ssRunner.LogDir = tempDir; // Replace XML path to the log being replayed with the actual path from the temp directory. _ssRunner.Configuration.Sessions[0].ReplayFrom = origLogPath; for (int p = 0; p < _ssRunner.Configuration.LocalPlayers.Length; ++p) { _ssRunner.Configuration.LocalPlayers[p].CreationParameters.Set("ReplayFrom", origLogPath); } _ssRunner.Run(); string hint; bool comparisonResult = GameLogComparer.Compare(_ssRunner.Configuration.Sessions[0].ReplayFrom.Get(Props.Global), _ssRunner.CurrentLogFile, out hint, int.MaxValue); Console.WriteLine("Original log:" + _ssRunner.Configuration.Sessions[0].ReplayFrom); Console.WriteLine("Replayed log:" + _ssRunner.CurrentLogFile); Console.WriteLine(hint); Assert.IsTrue(comparisonResult); }