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.
- Loading branch information
Showing
12 changed files
with
169 additions
and
188 deletions.
There are no files selected for viewing
81 changes: 21 additions & 60 deletions
81
Tests/Cosmos.TestRunner.Core/DefaultEngineConfiguration.cs
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 |
---|---|---|
@@ -1,72 +1,33 @@ | ||
using Cosmos.Build.Common; | ||
using System; | ||
using System.Reflection; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using Cosmos.Build.Common; | ||
|
||
namespace Cosmos.TestRunner.Core | ||
{ | ||
public static class DefaultEngineConfiguration | ||
public class DefaultEngineConfiguration : IEngineConfiguration | ||
{ | ||
public static void Apply(Engine engine) | ||
{ | ||
if (engine == null) | ||
{ | ||
throw new ArgumentNullException("engine"); | ||
} | ||
|
||
// Sets the time before an error is registered. For example if set to 60 then if a kernel runs for more than 60 seconds then | ||
// that kernel will be marked as a failure and terminated | ||
engine.AllowedSecondsInKernel = 6000; | ||
|
||
// If you want to test only specific platforms, add them to the list, like next line. By default, all platforms are run. | ||
engine.RunTargets.Add(RunTargetEnum.Bochs); | ||
//engine.RunTargets.Add(RunTargetEnum.VMware); | ||
//engine.RunTargets.Add(RunTargetEnum.HyperV); | ||
|
||
// If you're working on the compiler (or other lower parts), you can choose to run the compiler in process | ||
// one thing to keep in mind though, is that this only works with 1 kernel at a time! | ||
engine.DebugIL2CPU = false; | ||
engine.TraceAssembliesLevel = TraceAssemblies.User; | ||
//engine.EnableStackCorruptionChecks = false; | ||
engine.KernelPkg = "X86"; | ||
|
||
engine.EnableStackCorruptionChecks = true; | ||
engine.StackCorruptionChecksLevel = StackCorruptionDetectionLevel.AllInstructions; | ||
public virtual int AllowedSecondsInKernel => 6000; | ||
|
||
//engine.RunWithGDB = true; | ||
//engine.StartBochsDebugGui = true; | ||
|
||
// Select kernels to be tested by adding them to the engine | ||
foreach (var xType in TestKernelSets.GetKernelTypesToRun()) | ||
public virtual IEnumerable<RunTargetEnum> RunTargets | ||
{ | ||
get | ||
{ | ||
engine.AddKernel(xType.GetTypeInfo().Assembly.Location); | ||
yield return RunTargetEnum.Bochs; | ||
//yield return RunTargetEnum.VMware; | ||
//yield return RunTargetEnum.HyperV; | ||
} | ||
} | ||
|
||
//engine.AddKernel(typeof(Cosmos.Compiler.Tests.TypeSystem.Kernel).Assembly.Location); | ||
//engine.AddKernel(typeof(VGACompilerCrash.Kernel).Assembly.Location); | ||
//engine.AddKernel(typeof(Cosmos.Compiler.Tests.Bcl.Kernel).Assembly.Location); | ||
//engine.AddKernel(typeof(Cosmos.Compiler.Tests.SingleEchoTest.Kernel).Assembly.Location); | ||
//engine.AddKernel(typeof(Cosmos.Compiler.Tests.SimpleWriteLine.Kernel.Kernel).Assembly.Location); | ||
//engine.AddKernel(typeof(SimpleStructsAndArraysTest.Kernel).Assembly.Location); | ||
//engine.AddKernel(typeof(Cosmos.Compiler.Tests.Exceptions.Kernel).Assembly.Location); | ||
//engine.AddKernel(typeof(Cosmos.Compiler.Tests.MethodTests.Kernel).Assembly.Location); | ||
//engine.AddKernel(typeof(Cosmos.Kernel.Tests.Fat.Kernel).Assembly.Location); | ||
|
||
// Known bugs, therefore disabled for now: | ||
//engine.AddKernel(typeof(BoxingTests.Kernel).Assembly.Location); | ||
//engine.AddKernel(typeof(Cosmos.Compiler.Tests.MultidimensionalArrays.Kernel).Assembly.Location); | ||
|
||
// Experimental stuff: | ||
public virtual bool RunWithGDB => false; | ||
public virtual bool StartBochsDebugGUI => false; | ||
|
||
// end of known bugs | ||
public virtual bool DebugIL2CPU => false; | ||
public virtual string KernelPkg => String.Empty; | ||
public virtual TraceAssemblies TraceAssembliesLevel => TraceAssemblies.User; | ||
public virtual bool EnableStackCorruptionChecks => true; | ||
public virtual StackCorruptionDetectionLevel StackCorruptionChecksLevel => StackCorruptionDetectionLevel.AllInstructions; | ||
|
||
// double check: this check is in the engine, but lets put it here as well | ||
if (engine.DebugIL2CPU) | ||
{ | ||
if (engine.KernelsToRun.Count > 1 || engine.RunTargets.Count == 0 || engine.RunTargets.Count > 1) | ||
{ | ||
throw new InvalidOperationException("Can only run 1 kernel if IL2CPU is ran in-process!"); | ||
} | ||
} | ||
} | ||
public virtual IEnumerable<Type> KernelTypesToRun => TestKernelSets.GetStableKernelTypes(); | ||
} | ||
} |
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,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using Cosmos.Build.Common; | ||
|
||
namespace Cosmos.TestRunner.Core | ||
{ | ||
public interface IEngineConfiguration | ||
{ | ||
int AllowedSecondsInKernel { get; } | ||
IEnumerable<RunTargetEnum> RunTargets { get; } | ||
bool RunWithGDB { get; } | ||
bool StartBochsDebugGUI { get; } | ||
|
||
bool DebugIL2CPU { get; } | ||
string KernelPkg { get; } | ||
TraceAssemblies TraceAssembliesLevel { get; } | ||
bool EnableStackCorruptionChecks { get; } | ||
StackCorruptionDetectionLevel StackCorruptionChecksLevel { get; } | ||
|
||
IEnumerable<Type> KernelTypesToRun { get; } | ||
} | ||
} |
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,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using Cosmos.Build.Common; | ||
using Cosmos.TestRunner.Core; | ||
|
||
namespace Cosmos.TestRunner.UnitTest | ||
{ | ||
internal class EngineConfiguration : DefaultEngineConfiguration | ||
{ | ||
private Type mKernelType; | ||
|
||
public EngineConfiguration(Type aKernelType) | ||
{ | ||
mKernelType = aKernelType; | ||
} | ||
|
||
public override int AllowedSecondsInKernel => 1200; | ||
|
||
public override IEnumerable<RunTargetEnum> RunTargets | ||
{ | ||
get | ||
{ | ||
yield return RunTargetEnum.Bochs; | ||
} | ||
} | ||
|
||
public override StackCorruptionDetectionLevel StackCorruptionChecksLevel => StackCorruptionDetectionLevel.MethodFooters; | ||
|
||
public override IEnumerable<Type> KernelTypesToRun | ||
{ | ||
get | ||
{ | ||
yield return mKernelType; | ||
} | ||
} | ||
} | ||
} |
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,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
using NUnit.Framework; | ||
|
||
using Cosmos.TestRunner.Core; | ||
|
||
namespace Cosmos.TestRunner.UnitTest | ||
{ | ||
using Assert = NUnit.Framework.Assert; | ||
|
||
[TestFixture] | ||
public class KernelTests | ||
{ | ||
private static IEnumerable<Type> KernelsToRun => TestKernelSets.GetStableKernelTypes(); | ||
|
||
[TestCaseSource(nameof(KernelsToRun))] | ||
public void TestKernel(Type aKernelType) | ||
{ | ||
try | ||
{ | ||
Directory.SetCurrentDirectory(Path.GetDirectoryName(typeof(KernelTests).Assembly.Location)); | ||
|
||
var xEngine = new Engine(new EngineConfiguration(aKernelType)); | ||
xEngine.OutputHandler = new TestOutputHandler(); | ||
|
||
Assert.IsTrue(xEngine.Execute()); | ||
} | ||
catch (AssertionException) | ||
{ | ||
throw; | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine("Exception occurred: " + e.ToString()); | ||
Assert.Fail(); | ||
} | ||
} | ||
|
||
private class TestOutputHandler : OutputHandlerFullTextBase | ||
{ | ||
protected override void Log(string message) | ||
{ | ||
TestContext.WriteLine(String.Concat(DateTime.Now.ToString("hh:mm:ss.ffffff "), new string(' ', mLogLevel * 2), message)); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.