Initial Cosmos Unit Test Framework

This commit is contained in:
KebinuChiousu_cp 2010-02-22 01:28:15 +00:00
parent 79265a8b84
commit 84cd482a0a
7 changed files with 373 additions and 0 deletions

View file

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{75CEC24E-04AB-4CF4-A0CE-1400E78CDE8C}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Cosmos.UnitTests.Kernel</RootNamespace>
<AssemblyName>Cosmos.UnitTests.Kernel</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\source2\Build\Cosmos.Build.Common\Cosmos.Build.Common.csproj">
<Project>{0462E82B-8C29-41A9-8265-9C89038ADB29}</Project>
<Name>Cosmos.Build.Common</Name>
</ProjectReference>
<ProjectReference Include="..\Cosmos.Build.Windows\Cosmos.Compiler.Builder.csproj">
<Project>{1F0EDE86-F6D4-4355-9A97-10E90457770C}</Project>
<Name>Cosmos.Compiler.Builder</Name>
</ProjectReference>
<ProjectReference Include="..\Cosmos.UnitTests\Cosmos.UnitTests.csproj">
<Project>{668899F8-AAE0-41DE-B1CC-EF712E1234D7}</Project>
<Name>Cosmos.UnitTests</Name>
</ProjectReference>
<ProjectReference Include="..\Cosmos\Cosmos.Hardware\Cosmos.Hardware.csproj">
<Project>{CE50FE98-9AC4-4B4D-ADC7-31F6DCD28755}</Project>
<Name>Cosmos.Hardware</Name>
</ProjectReference>
<ProjectReference Include="..\Cosmos\Cosmos.Kernel\Cosmos.Kernel.csproj">
<Project>{A1F83D9F-2D44-4264-A08B-416797123018}</Project>
<Name>Cosmos.Kernel</Name>
</ProjectReference>
<ProjectReference Include="..\Cosmos\Cosmos.System\Cosmos.Sys.csproj">
<Project>{819DB8FC-5DA1-461F-83C9-2F5C88088C94}</Project>
<Name>Cosmos.Sys</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Cosmos.Compiler.Builder;
using Cosmos.Build.Common;
using Cosmos.Hardware;
using Cosmos.Kernel;
using Cosmos.UnitTests;
namespace Cosmos.UnitTests.Kernel
{
class Program
{
#region Cosmos Builder logic
// Most users wont touch this. This will call the Cosmos Build tool and launch QEMU
[STAThread]
static void Main(string[] args)
{
var xBuilder = new Builder();
Console.WriteLine("BuildPath = '{0}'", xBuilder.BuildPath);
xBuilder.TargetAssembly = typeof(Cosmos.UnitTests.Kernel.Program).Assembly;
var xEvent = new AutoResetEvent(false);
xBuilder.BuildCompleted += delegate { xEvent.Set(); };
xBuilder.LogMessage += delegate(LogSeverityEnum aSeverity, string aMessage)
{
Console.WriteLine("Log: {0} - {1}", aSeverity, aMessage);
};
var options = Cosmos.Compiler.Builder.BuildOptions.Load();
options.DebugMode = DebugMode.None;
options.DebugPortId = 0;
options.UseGDB = false;
options.CompileIL = true;
options.UseInternalAssembler = false; // force externel assemble and link
options.Target = "ISO";
xBuilder.BeginCompile(options);
// xBuilder.BeginCompile(options);
xEvent.WaitOne();
new MakeISOStep(options).Execute();
//From v0.9.1 Qemu requires forward slashes in path
String xBuildPath = xBuilder.BuildPath.Replace('\\', '/');
AutoResetEvent xTestEvent = new AutoResetEvent(false);
var xProcess = Cosmos.Compiler.Builder.Global.Call(xBuilder.ToolsPath + @"qemu\qemu.exe",
" -L ."
// CD ROM image
+ " -cdrom \"" + xBuilder.BuildPath.Replace('\\', '/') + "Cosmos.iso\""
// Boot CD ROM
+ " -boot d"
, xBuilder.ToolsPath + @"qemu", false, true);
System.Threading.Thread.Sleep(500); //give it time to launch
}
#endregion
// Main entry point of the kernel
public static void Init()
{
var xBoot = new Cosmos.Sys.Boot();
xBoot.Execute();
//Console.WriteLine("Edit Program.cs to create your own Operating System.");
RunTests();
Console.WriteLine("Press any key to shutdown...");
Console.Read();
Cosmos.Sys.Deboot.ShutDown();
}
public static void RunTests()
{
int tTotal = 0;
int tPass = 0;
string xMessage;
var xVar = new Cosmos.UnitTests.SimpleAddFunction();
tPass += xVar.Test();
tTotal += 1;
xVar = null;
xMessage = string.Concat(tPass, " test(s) passed, ");
xMessage = string.Concat(xMessage, tTotal);
xMessage = string.Concat(xMessage, " test(s) run.");
Console.WriteLine(xMessage);
Console.WriteLine();
}
}
}

View file

@ -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("Cosmos.UnitTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("END")]
[assembly: AssemblyProduct("Cosmos.UnitTests")]
[assembly: AssemblyCopyright("Copyright © END 2010")]
[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("27ff6438-1fcb-4bef-b8b4-5d511395ff50")]
// 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")]

View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{668899F8-AAE0-41DE-B1CC-EF712E1234D7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Cosmos.UnitTests</RootNamespace>
<AssemblyName>Cosmos.UnitTests</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="SimpleAddFunction.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -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("Cosmos.UnitTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("END")]
[assembly: AssemblyProduct("Cosmos.UnitTests")]
[assembly: AssemblyCopyright("Copyright © END 2010")]
[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("30dac53c-efc8-4d89-9dc9-cba070b5f4a4")]
// 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")]

View file

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Cosmos.UnitTests
{
public class SimpleAddFunction
{
public int Test()
{
int theValue = Add(1, 2);
if (theValue == 3) {
return 1;
} else {
return 0;
}
}
private int Add(int a, int b)
{
return a + b;
}
}
}

View file

@ -239,6 +239,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TempVSIP", "..\source2\VSIP
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Reynaldo", "Reynaldo", "{B8406314-B724-410E-8C79-E2C187ACDC65}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "KebinuChiousu", "KebinuChiousu", "{22BCACD7-7E12-47D3-B3F2-77B8C0D0CB6F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.UnitTests.Kernel", "Cosmos.UnitTests.Kernel\Cosmos.UnitTests.Kernel.csproj", "{75CEC24E-04AB-4CF4-A0CE-1400E78CDE8C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.UnitTests", "Cosmos.UnitTests\Cosmos.UnitTests.csproj", "{668899F8-AAE0-41DE-B1CC-EF712E1234D7}"
EndProject
Global
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 74
@ -1113,6 +1119,18 @@ Global
{54C786E5-FD14-4036-92AE-E9F25B71534B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{54C786E5-FD14-4036-92AE-E9F25B71534B}.Release|Any CPU.Build.0 = Release|Any CPU
{54C786E5-FD14-4036-92AE-E9F25B71534B}.Release|x86.ActiveCfg = Release|Any CPU
{75CEC24E-04AB-4CF4-A0CE-1400E78CDE8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{75CEC24E-04AB-4CF4-A0CE-1400E78CDE8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75CEC24E-04AB-4CF4-A0CE-1400E78CDE8C}.Debug|x86.ActiveCfg = Debug|Any CPU
{75CEC24E-04AB-4CF4-A0CE-1400E78CDE8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75CEC24E-04AB-4CF4-A0CE-1400E78CDE8C}.Release|Any CPU.Build.0 = Release|Any CPU
{75CEC24E-04AB-4CF4-A0CE-1400E78CDE8C}.Release|x86.ActiveCfg = Release|Any CPU
{668899F8-AAE0-41DE-B1CC-EF712E1234D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{668899F8-AAE0-41DE-B1CC-EF712E1234D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{668899F8-AAE0-41DE-B1CC-EF712E1234D7}.Debug|x86.ActiveCfg = Debug|Any CPU
{668899F8-AAE0-41DE-B1CC-EF712E1234D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{668899F8-AAE0-41DE-B1CC-EF712E1234D7}.Release|Any CPU.Build.0 = Release|Any CPU
{668899F8-AAE0-41DE-B1CC-EF712E1234D7}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -1213,6 +1231,7 @@ Global
{2DF5F17F-4890-4856-ADFD-4DE23282C3B7} = {A4478219-065D-4928-BB4D-4358CAD39A03}
{856EAFB8-D13E-4690-9ED8-6B5622D6AA41} = {A4478219-065D-4928-BB4D-4358CAD39A03}
{1DB35C80-00E4-41DE-AF1E-4A3ED148C352} = {A4478219-065D-4928-BB4D-4358CAD39A03}
{22BCACD7-7E12-47D3-B3F2-77B8C0D0CB6F} = {A4478219-065D-4928-BB4D-4358CAD39A03}
{28D7710D-5930-40BE-BB71-D30F01294EDF} = {9D82B35C-7133-4ADE-AA5C-0FFB2BFA8BA6}
{61535AF6-4A1E-4691-B2BC-039851EF4850} = {CD3F5E45-8B24-424F-ADF1-0211712F4CB7}
{54C786E5-FD14-4036-92AE-E9F25B71534B} = {CD3F5E45-8B24-424F-ADF1-0211712F4CB7}
@ -1225,5 +1244,7 @@ Global
{0F641748-FF03-4DA7-981B-1E9268330EE5} = {856EAFB8-D13E-4690-9ED8-6B5622D6AA41}
{D89DE0D3-FF3E-4F63-B15F-7302D998845E} = {856EAFB8-D13E-4690-9ED8-6B5622D6AA41}
{673EFE0A-176C-40CA-B4C3-F5328F838696} = {1DB35C80-00E4-41DE-AF1E-4A3ED148C352}
{75CEC24E-04AB-4CF4-A0CE-1400E78CDE8C} = {22BCACD7-7E12-47D3-B3F2-77B8C0D0CB6F}
{668899F8-AAE0-41DE-B1CC-EF712E1234D7} = {22BCACD7-7E12-47D3-B3F2-77B8C0D0CB6F}
EndGlobalSection
EndGlobal