forked from CosmosOS/Cosmos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring of kernel tester. Take out generic part of the runner, so…
… other targets (vmware, hyper-v in the future, etc) can also be tested.
- Loading branch information
Showing
10 changed files
with
208 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
using System; | ||
using System.Threading; | ||
using Cosmos.Debug.Common; | ||
using Cosmos.Debug.VSDebugEngine.Host; | ||
|
||
namespace Cosmos.TestRunner.Core | ||
{ | ||
partial class Engine | ||
{ | ||
// this file contains code handling situations when a kernel is running | ||
// most of this is debug stub related | ||
|
||
private void InitializeDebugConnector(DebugConnector debugConnector) | ||
{ | ||
if (debugConnector == null) | ||
{ | ||
throw new ArgumentNullException("debugConnector"); | ||
} | ||
|
||
debugConnector.CmdChannel = ChannelPacketReceived; | ||
debugConnector.CmdStarted = () => | ||
{ | ||
OutputHandler.LogMessage("DC: Started"); | ||
debugConnector.SendCmd(Vs2Ds.BatchEnd); | ||
}; | ||
debugConnector.Error = e => | ||
{ | ||
OutputHandler.LogMessage("DC Error: " + e.ToString()); | ||
OutputHandler.SetKernelTestResult(false, "DC Error"); | ||
mKernelResultSet = true; | ||
mBochsRunning = false; | ||
}; | ||
debugConnector.CmdText += s => | ||
{ | ||
if (s == "SYS_TestKernel_Completed") | ||
{ | ||
KernelTestCompleted(); | ||
return; | ||
} | ||
else if (s == "SYS_TestKernel_Failed") | ||
{ | ||
KernelTestFailed(); | ||
return; | ||
} | ||
else if (s == "SYS_TestKernel_AssertionSucceeded") | ||
{ | ||
KernelAssertionSucceeded(); | ||
return; | ||
} | ||
OutputHandler.LogMessage("Text from kernel: " + s); | ||
}; | ||
debugConnector.CmdMessageBox = s => | ||
{ | ||
//OutputHandler.LogMessage("MessageBox from kernel: " + s) | ||
}; | ||
debugConnector.CmdTrace = t => | ||
{ | ||
}; | ||
debugConnector.CmdBreak = t => | ||
{ | ||
}; | ||
} | ||
|
||
private void HandleRunning(DebugConnector debugConnector, Base host) | ||
{ | ||
if (debugConnector == null) | ||
{ | ||
throw new ArgumentNullException("debugConnector"); | ||
} | ||
if (host == null) | ||
{ | ||
throw new ArgumentNullException("host"); | ||
} | ||
host.Start(); | ||
try | ||
{ | ||
var xStartTime = DateTime.Now; | ||
mKernelResultSet = false; | ||
Interlocked.Exchange(ref mSucceededAssertions, 0); | ||
|
||
while (mBochsRunning) | ||
{ | ||
Thread.Sleep(50); | ||
|
||
if (Math.Abs(DateTime.Now.Subtract(xStartTime).TotalSeconds) > AllowedSecondsInKernel) | ||
{ | ||
OutputHandler.SetKernelTestResult(false, "Timeout exceeded"); | ||
mKernelResultSet = true; | ||
break; | ||
} | ||
} | ||
if (!mKernelResultSet) | ||
{ | ||
OutputHandler.SetKernelTestResult(true, null); | ||
} | ||
OutputHandler.SetKernelSucceededAssertionsCount(mSucceededAssertions); | ||
} | ||
finally | ||
{ | ||
host.Stop(); | ||
debugConnector.Dispose(); | ||
Thread.Sleep(50); | ||
} | ||
} | ||
|
||
private volatile bool mKernelResultSet; | ||
private int mSucceededAssertions; | ||
|
||
private void ChannelPacketReceived(byte arg1, byte arg2, byte[] arg3) | ||
{ | ||
OutputHandler.LogMessage(String.Format("ChannelPacketReceived, Channel = {0}, Command = {1}", arg1, arg2)); | ||
if (arg1 == 129) | ||
{ | ||
// for now, skip | ||
return; | ||
} | ||
if (arg1 == TestController.TestChannel) | ||
{ | ||
switch (arg2) | ||
{ | ||
case (byte)TestChannelCommandEnum.TestCompleted: | ||
KernelTestCompleted(); | ||
break; | ||
case (byte)TestChannelCommandEnum.TestFailed: | ||
KernelTestFailed(); | ||
break; | ||
case (byte)TestChannelCommandEnum.AssertionSucceeded: | ||
KernelAssertionSucceeded(); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
private void KernelAssertionSucceeded() | ||
{ | ||
Interlocked.Increment(ref mSucceededAssertions); | ||
} | ||
|
||
private void KernelTestFailed() | ||
{ | ||
OutputHandler.SetKernelTestResult(false, "Test failed"); | ||
mKernelResultSet = true; | ||
mBochsRunning = false; | ||
} | ||
|
||
private void KernelTestCompleted() | ||
{ | ||
mBochsRunning = false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Specialized; | ||
using System.IO; | ||
using System.Threading; | ||
using Cosmos.Build.Common; | ||
using Cosmos.Debug.Common; | ||
using Cosmos.Debug.VSDebugEngine.Host; | ||
|
||
namespace Cosmos.TestRunner.Core | ||
{ | ||
partial class Engine | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Cosmos.TestRunner.Core | ||
{ | ||
public enum RunTargetEnum | ||
{ | ||
Bochs, | ||
VMware | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,11 @@ public bool IsELF | |
get; | ||
set; | ||
} | ||
|
||
public RunTargetEnum RunTarget | ||
{ | ||
get; | ||
set; | ||
} | ||
} | ||
} |
Oops, something went wrong.