From 7207ae0bc559c55359b74377ec86ea6acf77ca2c Mon Sep 17 00:00:00 2001 From: Matthijs ter Woord Date: Sat, 18 Jul 2015 01:29:20 +0200 Subject: [PATCH] The tester now can run kernels in vmware (workstation for now) as well. --- .../Cosmos.TestRunner.Core.csproj | 1 + Tests/Cosmos.TestRunner.Core/Engine.Bochs.cs | 4 +- Tests/Cosmos.TestRunner.Core/Engine.Run.cs | 8 +- .../Cosmos.TestRunner.Core/Engine.Running.cs | 12 +- Tests/Cosmos.TestRunner.Core/Engine.VMware.cs | 18 +++ Tests/Cosmos.TestRunner.Core/Engine.cs | 9 +- .../OutputHandlerConsole.cs | 2 +- .../OutputHandlerFullConsole.cs | 121 ++++++++++++++++++ .../Cosmos.TestRunner.TestController/Enums.cs | 2 +- .../TestController.cs | 1 + 10 files changed, 163 insertions(+), 15 deletions(-) create mode 100644 Tests/Cosmos.TestRunner.Core/OutputHandlerFullConsole.cs diff --git a/Tests/Cosmos.TestRunner.Core/Cosmos.TestRunner.Core.csproj b/Tests/Cosmos.TestRunner.Core/Cosmos.TestRunner.Core.csproj index 773ae6b0a..f3966ea4f 100644 --- a/Tests/Cosmos.TestRunner.Core/Cosmos.TestRunner.Core.csproj +++ b/Tests/Cosmos.TestRunner.Core/Cosmos.TestRunner.Core.csproj @@ -61,6 +61,7 @@ + diff --git a/Tests/Cosmos.TestRunner.Core/Engine.Bochs.cs b/Tests/Cosmos.TestRunner.Core/Engine.Bochs.cs index 6ae9b5f22..3b2eb27e4 100644 --- a/Tests/Cosmos.TestRunner.Core/Engine.Bochs.cs +++ b/Tests/Cosmos.TestRunner.Core/Engine.Bochs.cs @@ -30,12 +30,10 @@ namespace Cosmos.TestRunner.Core xBochs.LogError = s => OutputHandler.LogDebugMessage(s); xBochs.LogOutput = s => OutputHandler.LogDebugMessage(s); - mBochsRunning = true; - HandleRunning(xDebugConnector, xBochs); } - private volatile bool mBochsRunning = true; + private volatile bool mKernelRunning = true; } } diff --git a/Tests/Cosmos.TestRunner.Core/Engine.Run.cs b/Tests/Cosmos.TestRunner.Core/Engine.Run.cs index 860f7f22b..7fe91f99d 100644 --- a/Tests/Cosmos.TestRunner.Core/Engine.Run.cs +++ b/Tests/Cosmos.TestRunner.Core/Engine.Run.cs @@ -13,7 +13,7 @@ namespace Cosmos.TestRunner.Core { partial class Engine { - private const int AllowedSecondsInKernel = 30; + private const int AllowedSecondsInKernel = 300; private void ExecuteKernel(string assemblyFileName, RunConfiguration configuration) { @@ -41,9 +41,9 @@ namespace Cosmos.TestRunner.Core case RunTargetEnum.Bochs: RunTask("RunISO", () => RunIsoInBochs(xIsoFile)); break; - //case RunTargetEnum.VMware: - // RunTask("RunISO", () => RunIsoInVMware(xIsoFile)); - // break; + case RunTargetEnum.VMware: + RunTask("RunISO", () => RunIsoInVMware(xIsoFile)); + break; default: throw new ArgumentOutOfRangeException("RunTarget " + configuration.RunTarget + " not implemented!"); } diff --git a/Tests/Cosmos.TestRunner.Core/Engine.Running.cs b/Tests/Cosmos.TestRunner.Core/Engine.Running.cs index a6b3cf1de..e21be66cc 100644 --- a/Tests/Cosmos.TestRunner.Core/Engine.Running.cs +++ b/Tests/Cosmos.TestRunner.Core/Engine.Running.cs @@ -28,7 +28,7 @@ namespace Cosmos.TestRunner.Core OutputHandler.LogMessage("DC Error: " + e.ToString()); OutputHandler.SetKernelTestResult(false, "DC Error"); mKernelResultSet = true; - mBochsRunning = false; + mKernelRunning = false; }; debugConnector.CmdText += s => { @@ -71,6 +71,8 @@ namespace Cosmos.TestRunner.Core { throw new ArgumentNullException("host"); } + mKernelRunning = true; + host.Start(); try { @@ -78,7 +80,7 @@ namespace Cosmos.TestRunner.Core mKernelResultSet = false; Interlocked.Exchange(ref mSucceededAssertions, 0); - while (mBochsRunning) + while (mKernelRunning) { Thread.Sleep(50); @@ -97,6 +99,7 @@ namespace Cosmos.TestRunner.Core } finally { + Console.WriteLine("Stopping now"); host.Stop(); debugConnector.Dispose(); Thread.Sleep(50); @@ -140,12 +143,13 @@ namespace Cosmos.TestRunner.Core { OutputHandler.SetKernelTestResult(false, "Test failed"); mKernelResultSet = true; - mBochsRunning = false; + mKernelRunning = false; } private void KernelTestCompleted() { - mBochsRunning = false; + Console.WriteLine("Test completed"); + mKernelRunning = false; } } } diff --git a/Tests/Cosmos.TestRunner.Core/Engine.VMware.cs b/Tests/Cosmos.TestRunner.Core/Engine.VMware.cs index 999766d58..7134d990e 100644 --- a/Tests/Cosmos.TestRunner.Core/Engine.VMware.cs +++ b/Tests/Cosmos.TestRunner.Core/Engine.VMware.cs @@ -10,5 +10,23 @@ namespace Cosmos.TestRunner.Core { partial class Engine { + private void RunIsoInVMware(string iso) + { + var xParams = new NameValueCollection(); + + xParams.Add("ISOFile", iso); + xParams.Add(BuildProperties.VisualStudioDebugPortString, "Pipe: Cosmos\\Serial"); + xParams.Add(BuildProperties.VMwareEditionString, "Workstation"); + + var xDebugConnector = new DebugConnectorPipeServer(DebugConnectorPipeServer.DefaultCosmosPipeName); + InitializeDebugConnector(xDebugConnector); + + var xVMware = new VMware(xParams, false); + xVMware.OnShutDown = (a, b) => + { + }; + + HandleRunning(xDebugConnector, xVMware); + } } } diff --git a/Tests/Cosmos.TestRunner.Core/Engine.cs b/Tests/Cosmos.TestRunner.Core/Engine.cs index 3855f5334..60259fc3a 100644 --- a/Tests/Cosmos.TestRunner.Core/Engine.cs +++ b/Tests/Cosmos.TestRunner.Core/Engine.cs @@ -80,8 +80,13 @@ namespace Cosmos.TestRunner.Core private IEnumerable GetRunConfigurations() { - yield return new RunConfiguration {IsELF = true}; - //yield return new RunConfiguration {IsELF = false}; + yield return new RunConfiguration { IsELF = true, RunTarget = RunTargetEnum.VMware }; + + //foreach (RunTargetEnum xTarget in Enum.GetValues(typeof(RunTargetEnum))) + //{ + // yield return new RunConfiguration {IsELF = true, RunTarget = xTarget}; + // //yield return new RunConfiguration { IsELF = false, RunTarget = xTarget }; + //} } } } diff --git a/Tests/Cosmos.TestRunner.Core/OutputHandlerConsole.cs b/Tests/Cosmos.TestRunner.Core/OutputHandlerConsole.cs index 4ecb4d2a5..6c6398b14 100644 --- a/Tests/Cosmos.TestRunner.Core/OutputHandlerConsole.cs +++ b/Tests/Cosmos.TestRunner.Core/OutputHandlerConsole.cs @@ -56,7 +56,7 @@ namespace Cosmos.TestRunner.Core public override void RunConfigurationStart(RunConfiguration configuration) { - Log(string.Format("Start configuration. IsELF = {0}", configuration.IsELF)); + Log(string.Format("Start configuration. IsELF = {0}, Target = {1}", configuration.IsELF, configuration.RunTarget)); mLogLevel++; } diff --git a/Tests/Cosmos.TestRunner.Core/OutputHandlerFullConsole.cs b/Tests/Cosmos.TestRunner.Core/OutputHandlerFullConsole.cs new file mode 100644 index 000000000..48c215170 --- /dev/null +++ b/Tests/Cosmos.TestRunner.Core/OutputHandlerFullConsole.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; + +namespace Cosmos.TestRunner.Core +{ + public class OutputHandlerFullConsole: OutputHandlerBase + { + private readonly Stopwatch mCurrentTaskStopwatch=new Stopwatch(); + private readonly Stopwatch mCurrentKernelStopwatch = new Stopwatch(); + private readonly Stopwatch mExecutionStopwatch = new Stopwatch(); + + public override void TaskStart(string taskName) + { + Log("Running task '" + taskName + "'"); + mCurrentTaskStopwatch.Reset(); + mCurrentTaskStopwatch.Start(); + mLogLevel ++; + } + + public override void TaskEnd(string taskName) + { + mCurrentTaskStopwatch.Stop(); + mLogLevel --; + Log("Done running task '" + taskName + "'. Took " + mCurrentTaskStopwatch.Elapsed); + } + + public override void UnhandledException(Exception exception) + { + Log("Unhandled exception: "+ exception.ToString()); + } + + public override void ExecutionEnd() + { + mLogLevel = 0; + Log("Done executing"); + Log("Took " + mExecutionStopwatch.Elapsed); + + Log(String.Format("{0} kernels succeeded their tests", mNumberOfSuccesses)); + Log(String.Format("{0} kernels failed their tests", mNumberOfFailures)); + } + + public override void ExecutionStart() + { + mLogLevel = 0; + Log("Start executing"); + mExecutionStopwatch.Reset(); + mExecutionStopwatch.Start(); + mLogLevel = 1; + } + + public override void LogDebugMessage(string message) + { + + } + + public override void RunConfigurationStart(RunConfiguration configuration) + { + Log(string.Format("Start configuration. IsELF = {0}, Target = {1}", configuration.IsELF, configuration.RunTarget)); + mLogLevel++; + } + + public override void RunConfigurationEnd(RunConfiguration configuration) + { + mLogLevel --; + } + + public override void LogError(string message) + { + Log("Error: " + message); + } + + public override void LogMessage(string message) + { + Log("Msg: " + message); + } + + public override void ExecuteKernelEnd(string assemblyName) + { + mCurrentKernelStopwatch.Stop(); + Log("Done running kernel. Took " + mCurrentKernelStopwatch.Elapsed); + mLogLevel--; + } + + public override void ExecuteKernelStart(string assemblyName) + { + Log("Starting kernel '" + assemblyName + "'"); + mCurrentKernelStopwatch.Reset(); + mCurrentKernelStopwatch.Start(); + mLogLevel++; + } + + private int mLogLevel; + private void Log(string message) + { + Console.Write(DateTime.Now.ToString("hh:mm:ss.ffffff ")); + Console.Write(new String(' ', mLogLevel * 2)); + Console.WriteLine(message); + } + + public override void SetKernelTestResult(bool succeeded, string message) + { + Log(string.Format("Success = {0}, Message = '{1}'", succeeded, message)); + if (succeeded) + { + mNumberOfSuccesses++; + } + else + { + mNumberOfFailures++; + } + } + + private int mNumberOfSuccesses = 0; + private int mNumberOfFailures = 0; + + public override void SetKernelSucceededAssertionsCount(int succeededAssertions) + { + } + } +} diff --git a/Tests/Cosmos.TestRunner.TestController/Enums.cs b/Tests/Cosmos.TestRunner.TestController/Enums.cs index af1d4b6d7..70d949bc1 100644 --- a/Tests/Cosmos.TestRunner.TestController/Enums.cs +++ b/Tests/Cosmos.TestRunner.TestController/Enums.cs @@ -1,6 +1,6 @@ namespace Cosmos.TestRunner { - public enum TestChannelCommandEnum + public enum TestChannelCommandEnum: byte { TestCompleted = 0, TestFailed = 1, diff --git a/Tests/Cosmos.TestRunner.TestController/TestController.cs b/Tests/Cosmos.TestRunner.TestController/TestController.cs index f6c3240e6..11f1a0b03 100644 --- a/Tests/Cosmos.TestRunner.TestController/TestController.cs +++ b/Tests/Cosmos.TestRunner.TestController/TestController.cs @@ -23,6 +23,7 @@ namespace Cosmos.TestRunner public static unsafe void Completed() { Debugger.SendChannelCommand(TestChannel, (byte)TestChannelCommandEnum.TestCompleted); + Debugger.Send("Test completed"); while (true) ; }