2020-03-05 13:50:48 -05:00
|
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Tools.DotNETCommon;
|
|
|
|
|
|
using UnrealBuildTool;
|
|
|
|
|
|
|
|
|
|
|
|
namespace AutomationTool.Benchmark
|
|
|
|
|
|
{
|
|
|
|
|
|
class BenchmarkRunEditorTask : BenchmarkEditorTaskBase
|
|
|
|
|
|
{
|
2020-03-09 17:03:55 -04:00
|
|
|
|
public BenchmarkRunEditorTask(FileReference InProjectFile, DDCTaskOptions InOptions, string InEditorArgs="")
|
|
|
|
|
|
: base(InProjectFile, InOptions, InEditorArgs)
|
2020-03-05 13:50:48 -05:00
|
|
|
|
{
|
2020-03-09 17:03:55 -04:00
|
|
|
|
TaskName = string.Format("{0} PIE", ProjectName, BuildHostPlatform.Current.Platform);
|
2020-03-05 13:50:48 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override bool PerformPrequisites()
|
|
|
|
|
|
{
|
|
|
|
|
|
// build editor
|
|
|
|
|
|
BuildTarget Command = new BuildTarget();
|
2020-03-08 19:25:07 -04:00
|
|
|
|
Command.ProjectName = ProjectFile != null ? ProjectFile.GetFileNameWithoutAnyExtensions() : null;
|
2020-03-05 13:50:48 -05:00
|
|
|
|
Command.Platforms = BuildHostPlatform.Current.Platform.ToString();
|
|
|
|
|
|
Command.Targets = "Editor";
|
2020-03-08 19:25:07 -04:00
|
|
|
|
Command.NoTools = false;
|
2020-03-05 13:50:48 -05:00
|
|
|
|
|
|
|
|
|
|
if (Command.Execute() != ExitCode.Success)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2020-03-08 19:25:07 -04:00
|
|
|
|
|
2020-03-07 05:47:20 -05:00
|
|
|
|
// if they want a hot DDC then do the test one time with no timing
|
2020-03-09 17:03:55 -04:00
|
|
|
|
if (TaskOptions.HasFlag(DDCTaskOptions.HotDDC))
|
2020-03-05 13:50:48 -05:00
|
|
|
|
{
|
|
|
|
|
|
RunEditorAndWaitForMapLoad();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-08 19:25:07 -04:00
|
|
|
|
base.PerformPrequisites();
|
|
|
|
|
|
|
2020-03-05 13:50:48 -05:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static IProcessResult CurrentProcess = null;
|
2020-03-08 19:25:07 -04:00
|
|
|
|
static DateTime LastStdOutTime = DateTime.Now;
|
2020-03-07 05:47:20 -05:00
|
|
|
|
//static bool TestCompleted = false;
|
2020-03-05 13:50:48 -05:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A filter that suppresses all output od stdout/stderr
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="Message"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
static string EndOnMapCheckFilter(string Message)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (CurrentProcess != null)
|
|
|
|
|
|
{
|
2020-03-08 19:25:07 -04:00
|
|
|
|
lock (CurrentProcess)
|
2020-03-05 13:50:48 -05:00
|
|
|
|
{
|
2020-03-08 19:25:07 -04:00
|
|
|
|
if (Message.Contains("TEST COMPLETE"))
|
|
|
|
|
|
{
|
|
|
|
|
|
Log.TraceInformation("Automation test reported as complete.");
|
|
|
|
|
|
//TestCompleted = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LastStdOutTime = DateTime.Now;
|
2020-03-05 13:50:48 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return Message;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-11 13:02:02 -04:00
|
|
|
|
private static string MakeValidFileName(string name)
|
|
|
|
|
|
{
|
|
|
|
|
|
string invalidChars = System.Text.RegularExpressions.Regex.Escape(new string(System.IO.Path.GetInvalidFileNameChars()));
|
|
|
|
|
|
string invalidRegStr = string.Format(@"([{0}]*\.+$)|([{0}]+)", invalidChars);
|
|
|
|
|
|
|
|
|
|
|
|
return System.Text.RegularExpressions.Regex.Replace(name, invalidRegStr, "_");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-05 13:50:48 -05:00
|
|
|
|
protected bool RunEditorAndWaitForMapLoad()
|
|
|
|
|
|
{
|
|
|
|
|
|
string ProjectArg = ProjectFile != null ? ProjectFile.ToString() : "";
|
|
|
|
|
|
string EditorPath = HostPlatform.Current.GetUE4ExePath("UE4Editor.exe");
|
2020-03-11 13:02:02 -04:00
|
|
|
|
string LogArg = string.Format("-log={0}.log", MakeValidFileName(GetFullTaskName()).Replace(" ", "_"));
|
2020-03-16 16:25:17 -04:00
|
|
|
|
string Arguments = string.Format("{0} {1} -execcmds=\"automation runtest System.Maps.PIE;Quit\" -stdout -FullStdOutLogOutput -unattended {2}", ProjectArg, EditorArgs, LogArg);
|
2020-03-05 13:50:48 -05:00
|
|
|
|
|
2020-03-11 13:02:02 -04:00
|
|
|
|
if (TaskOptions.HasFlag(DDCTaskOptions.NoSharedDDC))
|
2020-03-08 19:25:07 -04:00
|
|
|
|
{
|
|
|
|
|
|
Arguments += (" -ddc=noshared");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-05 13:50:48 -05:00
|
|
|
|
var RunOptions = CommandUtils.ERunOptions.AllowSpew | CommandUtils.ERunOptions.NoWaitForExit;
|
|
|
|
|
|
|
|
|
|
|
|
var SpewDelegate = new ProcessResult.SpewFilterCallbackType(EndOnMapCheckFilter);
|
|
|
|
|
|
|
2020-03-07 05:47:20 -05:00
|
|
|
|
//TestCompleted = false;
|
2020-03-08 19:25:07 -04:00
|
|
|
|
LastStdOutTime = DateTime.Now;
|
2020-03-05 13:50:48 -05:00
|
|
|
|
CurrentProcess = CommandUtils.Run(EditorPath, Arguments, Options: RunOptions, SpewFilterCallback: SpewDelegate);
|
|
|
|
|
|
|
|
|
|
|
|
DateTime StartTime = DateTime.Now;
|
|
|
|
|
|
|
2020-03-09 17:03:55 -04:00
|
|
|
|
int MaxWaitMins = 90;
|
2020-03-05 13:50:48 -05:00
|
|
|
|
|
|
|
|
|
|
while (!CurrentProcess.HasExited)
|
|
|
|
|
|
{
|
|
|
|
|
|
Thread.Sleep(5 * 1000);
|
|
|
|
|
|
|
2020-03-08 19:25:07 -04:00
|
|
|
|
lock (CurrentProcess)
|
2020-03-05 13:50:48 -05:00
|
|
|
|
{
|
2020-03-08 19:25:07 -04:00
|
|
|
|
if ((LastStdOutTime - StartTime).TotalMinutes >= MaxWaitMins)
|
|
|
|
|
|
{
|
|
|
|
|
|
Log.TraceError("Gave up waiting for task after {0} minutes of no output", MaxWaitMins);
|
|
|
|
|
|
CurrentProcess.ProcessObject.Kill();
|
|
|
|
|
|
}
|
2020-03-05 13:50:48 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-07 05:47:20 -05:00
|
|
|
|
int ExitCode = CurrentProcess.ExitCode;
|
2020-03-05 13:50:48 -05:00
|
|
|
|
CurrentProcess = null;
|
2020-03-07 05:47:20 -05:00
|
|
|
|
|
|
|
|
|
|
return ExitCode == 0;
|
2020-03-05 13:50:48 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override bool PerformTask()
|
|
|
|
|
|
{
|
|
|
|
|
|
return RunEditorAndWaitForMapLoad();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|