From cc4f82c95affdccfd2275487ca9ec484a96f2007 Mon Sep 17 00:00:00 2001 From: mterwoord_cp <7cd3fd84a0151ea055c2f79e4d2eef9576fe9afesxUZAwxD> Date: Sun, 24 Feb 2008 16:15:24 +0000 Subject: [PATCH] Basic test harness --- source/Cosmos.sln | 16 ++++- source/Indy.IL2CPU.IL.X86/Ldelema.cs | 1 - source/TestKernel/Attributes.cs | 26 +++++++ source/TestKernel/Program.cs | 64 +++++++++++++++++ source/TestKernel/Properties/AssemblyInfo.cs | 36 ++++++++++ source/TestKernel/TestGroups.cs | 9 +++ source/TestKernel/TestKernel.csproj | 72 +++++++++++++++++++ source/TestKernel/TestKernel.csproj.vspscc | 10 +++ source/TestKernel/Tests/NoInit/StringTests.cs | 27 +++++++ 9 files changed, 259 insertions(+), 2 deletions(-) create mode 100644 source/TestKernel/Attributes.cs create mode 100644 source/TestKernel/Program.cs create mode 100644 source/TestKernel/Properties/AssemblyInfo.cs create mode 100644 source/TestKernel/TestGroups.cs create mode 100644 source/TestKernel/TestKernel.csproj create mode 100644 source/TestKernel/TestKernel.csproj.vspscc create mode 100644 source/TestKernel/Tests/NoInit/StringTests.cs diff --git a/source/Cosmos.sln b/source/Cosmos.sln index 5b3ec4fd0..839b5e7e9 100644 --- a/source/Cosmos.sln +++ b/source/Cosmos.sln @@ -79,9 +79,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoitoiusTest", "MoitoiusTes EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JoelBTest", "JoelBTest\JoelBTest.csproj", "{AEC28E7E-1ABB-4ABC-8CE1-B74D9DC9B80E}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestSuite", "TestSuite", "{7EB6E2FF-74C8-4F59-9923-EB8EF1DE098E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestKernel", "TestKernel\TestKernel.csproj", "{8F2D5231-CDE5-48FA-9D26-D4305B01FD3C}" +EndProject Global GlobalSection(TeamFoundationVersionControl) = preSolution - SccNumberOfProjects = 33 + SccNumberOfProjects = 34 SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} SccTeamFoundationServer = https://tfs04.codeplex.com/ SccLocalPath0 = . @@ -213,6 +217,10 @@ Global SccProjectTopLevelParentUniqueName32 = Cosmos.sln SccProjectName32 = Cosmos.Build.Tasks SccLocalPath32 = Cosmos.Build.Tasks + SccProjectUniqueName33 = TestKernel\\TestKernel.csproj + SccProjectTopLevelParentUniqueName33 = Cosmos.sln + SccProjectName33 = TestKernel + SccLocalPath33 = TestKernel EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -344,6 +352,10 @@ Global {AEC28E7E-1ABB-4ABC-8CE1-B74D9DC9B80E}.Debug|Any CPU.Build.0 = Debug|Any CPU {AEC28E7E-1ABB-4ABC-8CE1-B74D9DC9B80E}.Release|Any CPU.ActiveCfg = Release|Any CPU {AEC28E7E-1ABB-4ABC-8CE1-B74D9DC9B80E}.Release|Any CPU.Build.0 = Release|Any CPU + {8F2D5231-CDE5-48FA-9D26-D4305B01FD3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8F2D5231-CDE5-48FA-9D26-D4305B01FD3C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8F2D5231-CDE5-48FA-9D26-D4305B01FD3C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8F2D5231-CDE5-48FA-9D26-D4305B01FD3C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -383,5 +395,7 @@ Global {605F8D53-66FA-4BEC-844E-F63209B855C9} = {EBF602FE-8AFC-408D-A9F1-560C35651090} {B69B89D4-54FC-41DF-B5D7-EE674CF60343} = {EBF602FE-8AFC-408D-A9F1-560C35651090} {AEC28E7E-1ABB-4ABC-8CE1-B74D9DC9B80E} = {EBF602FE-8AFC-408D-A9F1-560C35651090} + {7EB6E2FF-74C8-4F59-9923-EB8EF1DE098E} = {EBF602FE-8AFC-408D-A9F1-560C35651090} + {8F2D5231-CDE5-48FA-9D26-D4305B01FD3C} = {7EB6E2FF-74C8-4F59-9923-EB8EF1DE098E} EndGlobalSection EndGlobal diff --git a/source/Indy.IL2CPU.IL.X86/Ldelema.cs b/source/Indy.IL2CPU.IL.X86/Ldelema.cs index b4e7fdc5f..c9c6838a3 100644 --- a/source/Indy.IL2CPU.IL.X86/Ldelema.cs +++ b/source/Indy.IL2CPU.IL.X86/Ldelema.cs @@ -17,7 +17,6 @@ namespace Indy.IL2CPU.IL.X86 { } public static void Assemble(CPU.Assembler aAssembler, int aElementSize) { - new CPUx86.Call("_CODE_REQUESTED_BREAK_"); aAssembler.StackContents.Pop(); aAssembler.StackContents.Pop(); aAssembler.StackContents.Push(new StackContent(4, typeof(uint))); diff --git a/source/TestKernel/Attributes.cs b/source/TestKernel/Attributes.cs new file mode 100644 index 000000000..ef3217e3e --- /dev/null +++ b/source/TestKernel/Attributes.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace TestKernel { + [AttributeUsage(AttributeTargets.Method)] + public sealed class TestAttribute: Attribute { + public TestAttribute() { + } + + public string TestGroup { + get; + set; + } + + public string Description { + get; + set; + } + + public bool IsExperimental { + get; + set; + } + } +} diff --git a/source/TestKernel/Program.cs b/source/TestKernel/Program.cs new file mode 100644 index 000000000..23f7bdbfd --- /dev/null +++ b/source/TestKernel/Program.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Cosmos.Build.Windows; + +namespace TestKernel { + class Program { + [STAThread] + public static void Main(string[] aArgs) { + if (aArgs.Length == 0) { + var xBuilder = new Builder(); + xBuilder.Build(); + } else { + List> xTests = new List>(); + #region detect all current tests + foreach (var xType in typeof(Program).Assembly.GetTypes()) { + foreach (var xMethod in xType.GetMethods()) { + var xAttrib = xMethod.GetCustomAttributes(typeof(TestAttribute), true).FirstOrDefault() as TestAttribute; + if (xAttrib != null) { + xTests.Add(new KeyValuePair(xType.FullName.Replace('+', '.') + "." + xMethod.Name, xAttrib)); + } + } + } + #endregion + Console.WriteLine("public static void Init() {"); + Console.WriteLine("string xTestResult=null;"); + foreach (var xTest in (from item in xTests + where item.Value.TestGroup == aArgs[0] && ((!item.Value.IsExperimental) || ((aArgs.Length > 1) && (aArgs[1] == "-experimental"))) + select item)) { + Console.WriteLine("Console.WriteLine(\"Running test '{0}'\");", xTest.Value.Description); + Console.WriteLine("xTestResult = {0}();", xTest.Key); + Console.WriteLine("Console.Write(\" \");"); + Console.WriteLine("if (xTestResult == null) {"); + Console.WriteLine("Console.WriteLine(\"Success\");"); + Console.WriteLine("} else {"); + Console.WriteLine("Console.Write(\"Error: \");"); + Console.WriteLine("Console.WriteLine(xTestResult);}"); + } + + Console.WriteLine("Console.WriteLine(\"All tests executed!\");"); + Console.WriteLine("while (true)"); + Console.WriteLine(";"); + Console.WriteLine("}"); + } + } + + public static void Init() { + string xTestResult = null; + Console.WriteLine("Running test 'System.String_EmbeddedStringContents'"); + xTestResult = TestKernel.Tests.NoInit.StringTests.TestEmbedded(); + Console.Write(" "); + if (xTestResult == null) { + Console.WriteLine("Success"); + } else { + Console.Write("Error: "); + Console.WriteLine(xTestResult); + } + Console.WriteLine("All tests executed!"); + while (true) + ; + } + } +} diff --git a/source/TestKernel/Properties/AssemblyInfo.cs b/source/TestKernel/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..a56e59437 --- /dev/null +++ b/source/TestKernel/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TestKernel")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TestKernel")] +[assembly: AssemblyCopyright("Copyright © 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("afb65b51-4aa0-407c-9c36-42fe4c90ef63")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/source/TestKernel/TestGroups.cs b/source/TestKernel/TestGroups.cs new file mode 100644 index 000000000..feed4e8f7 --- /dev/null +++ b/source/TestKernel/TestGroups.cs @@ -0,0 +1,9 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace TestKernel { + public static class TestGroups { + public const string NoInit = "NoInit"; + } +} diff --git a/source/TestKernel/TestKernel.csproj b/source/TestKernel/TestKernel.csproj new file mode 100644 index 000000000..ee1cc81d5 --- /dev/null +++ b/source/TestKernel/TestKernel.csproj @@ -0,0 +1,72 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {8F2D5231-CDE5-48FA-9D26-D4305B01FD3C} + Exe + Properties + TestKernel + TestKernel + v3.5 + 512 + SAK + SAK + SAK + SAK + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + {1F0EDE86-F6D4-4355-9A97-10E90457770C} + Cosmos.Build.Windows + + + + + \ No newline at end of file diff --git a/source/TestKernel/TestKernel.csproj.vspscc b/source/TestKernel/TestKernel.csproj.vspscc new file mode 100644 index 000000000..feffdecaa --- /dev/null +++ b/source/TestKernel/TestKernel.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/source/TestKernel/Tests/NoInit/StringTests.cs b/source/TestKernel/Tests/NoInit/StringTests.cs new file mode 100644 index 000000000..28b645393 --- /dev/null +++ b/source/TestKernel/Tests/NoInit/StringTests.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace TestKernel.Tests.NoInit { + public static class StringTests { + [Test(TestGroup=TestGroups.NoInit, Description="System.String_EmbeddedStringContents", IsExperimental=false)] + public static string TestEmbedded() { + string MyString = "Hello"; + if (MyString == null) + return "MyString is null"; + if (MyString.Length != 5) + return "MyString Length is not 5"; + if (MyString[0] != 'H') + return "MyString[0] != 'H'"; + if (MyString[1] != 'e') + return "MyString[1] != 'e'"; + if (MyString[2] != 'l') + return "MyString[2] != 'l'"; + if (MyString[3] != 'l') + return "MyString[3] != 'l'"; + if (MyString[4] != 'o') + return "MyString[4] != 'o'"; + return null; + } + } +} \ No newline at end of file