Fix the cancelation of a process due timeout

This commit is contained in:
Diego Garbervetsky 2016-08-30 12:36:41 -07:00
Родитель 8288f13ea8
Коммит 1da48f0366
1 изменённых файлов: 14 добавлений и 8 удалений

Просмотреть файл

@ -15,6 +15,7 @@ namespace ScopeAnalysisBulkScripts
{ {
private long maxTime = 0; private long maxTime = 0;
private long totalTime = 0; private long totalTime = 0;
private int totalCanceled = 0;
static void Main(string[] args) static void Main(string[] args)
{ {
@ -23,7 +24,7 @@ namespace ScopeAnalysisBulkScripts
var inputFolder = @"\\madanm2\parasail2\TFS\parasail\ScopeSurvey\AutoDownloader\bin\Debug"; var inputFolder = @"\\madanm2\parasail2\TFS\parasail\ScopeSurvey\AutoDownloader\bin\Debug";
//var inputFolder = @"D:\Madam3"; //var inputFolder = @"D:\Madam3";
inputFolder = @"C:\temp\Madam"; //inputFolder = @"C:\temp\Madam";
var inputList = @"C:\Temp\Zvo\inputDlls.txt"; var inputList = @"C:\Temp\Zvo\inputDlls.txt";
//var inputList = @"C:\Temp\Zvo\sampleDlls.txt"; //var inputList = @"C:\Temp\Zvo\sampleDlls.txt";
@ -35,13 +36,13 @@ namespace ScopeAnalysisBulkScripts
var bulkAnalysis = new BulkAnalysis(); var bulkAnalysis = new BulkAnalysis();
// var dllList = bulkAnalysis.LoadListFromFile(inputList); // var dllList = bulkAnalysis.LoadListFromFile(inputList);
//var dllList = bulkAnalysis.LoadFromDirectory(inputFolder); var dllList = bulkAnalysis.LoadFromDirectory(inputFolder);
var dllList = bulkAnalysis.LoadSarifFromDirectory(inputFolder); //var dllList = bulkAnalysis.LoadSarifFromDirectory(inputFolder);
Stopwatch stopWatch = new Stopwatch(); Stopwatch stopWatch = new Stopwatch();
stopWatch.Start(); stopWatch.Start();
//bulkAnalysis.ProcessDLLs(dllList, analysisClient, outputFolder, outputFolder); bulkAnalysis.ProcessDLLs(dllList, analysisClient, outputFolder, outputFolder);
bulkAnalysis.AnalyzeOutput(dllList, outputAnalyzer, outputFolder); bulkAnalysis.AnalyzeOutput(dllList, outputAnalyzer, outputFolder);
@ -60,6 +61,7 @@ namespace ScopeAnalysisBulkScripts
outputStream.WriteLine("Bulk Analysis finished on {0} dlls", dllList.Count); outputStream.WriteLine("Bulk Analysis finished on {0} dlls", dllList.Count);
outputStream.WriteLine("Total time {0} seconds", ts.Seconds); outputStream.WriteLine("Total time {0} seconds", ts.Seconds);
outputStream.WriteLine("Max time for one analysis {0} ms", bulkAnalysis.maxTime); outputStream.WriteLine("Max time for one analysis {0} ms", bulkAnalysis.maxTime);
outputStream.WriteLine("Total canceled {0}", bulkAnalysis.totalCanceled);
outputStream.Close(); outputStream.Close();
// System.Console.ReadKey(); // System.Console.ReadKey();
@ -113,8 +115,12 @@ namespace ScopeAnalysisBulkScripts
scopeAnalysisProcess.StartInfo.UseShellExecute = false; scopeAnalysisProcess.StartInfo.UseShellExecute = false;
scopeAnalysisProcess.StartInfo.CreateNoWindow = true; scopeAnalysisProcess.StartInfo.CreateNoWindow = true;
scopeAnalysisProcess.Start(); scopeAnalysisProcess.Start();
scopeAnalysisProcess.WaitForExit(5*60*1000); if (!scopeAnalysisProcess.WaitForExit(3 * 60 * 1000))
stopWatch.Start(); {
scopeAnalysisProcess.Kill();
totalCanceled++;
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed; TimeSpan ts = stopWatch.Elapsed;
if (ts.Milliseconds > maxTime) if (ts.Milliseconds > maxTime)
maxTime = ts.Milliseconds; maxTime = ts.Milliseconds;
@ -138,8 +144,8 @@ namespace ScopeAnalysisBulkScripts
{ {
var folder = Path.GetDirectoryName(input); var folder = Path.GetDirectoryName(input);
string[] directories = folder.Split(Path.DirectorySeparatorChar); string[] directories = folder.Split(Path.DirectorySeparatorChar);
//var sarifFilePath = Path.Combine(outputFolder, directories.Last()) + "_" + Path.ChangeExtension(Path.GetFileName(input), ".sarif"); var sarifFilePath = Path.Combine(outputFolder, directories.Last()) + "_" + Path.ChangeExtension(Path.GetFileName(input), ".sarif");
var sarifFilePath = input; //var sarifFilePath = input;
var comparerProcess = new Process(); var comparerProcess = new Process();
comparerProcess.StartInfo.FileName = outputAnalyzerPath; comparerProcess.StartInfo.FileName = outputAnalyzerPath;