Skip to content

Commit

Permalink
Merge pull request #598 from Arakis/036-add-unit-tests-to-appveyor
Browse files Browse the repository at this point in the history
036 add unit tests to appveyor
  • Loading branch information
tgiphil committed Feb 10, 2019
2 parents 84252cd + 5a7b57d commit 8ead08e
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 14 deletions.
7 changes: 5 additions & 2 deletions Source/Compile.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#cp ../3rdParty/*.dll ../bin/
cd $(dirname $0) #Go to directory containing this script, if called from elsewhre
mono ../Tools/nuget/nuget.exe restore
msbuild /m
mono ../Tools/nuget/nuget.exe restore Mosa.Tool.Mosactl.sln
mono ../Tools/nuget/nuget.exe restore Mosa.sln

msbuild Mosa.Tool.Mosactl.sln /m
msbuild Mosa.sln /m
22 changes: 22 additions & 0 deletions Source/Mosa.Tool.Mosactl/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ public void Run(List<string> args)
if (!TaskTest(args))
Environment.Exit(1);
break;
case "unittest":
if (!TaskUnitTest(args))
Environment.Exit(1);
break;
case "debug":
TaskDebug(args);
break;
Expand Down Expand Up @@ -310,6 +314,22 @@ public bool TaskTest(List<string> args)
}
}

public bool TaskUnitTest(List<string> args)
{
OsName = "UnitTests";

if (!TaskCILBuild(CheckType.changed, args))
return false;

if (!CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Utility.UnitTests/Mosa.Utility.UnitTests.csproj", "/p:Configuration=Debug", "/p:Platform=\"AnyCPU\"", "-verbosity:minimal"))
return false;

if (!CallMonoProcess(BinDir, "Mosa.Utility.UnitTests.exe"))
return false;

return true;
}

private bool CallQemu(bool nographic, Action<string, Process> OnKernelLog)
{
var logFile = ExpandKernelBinPath(OsName) + ".log";
Expand Down Expand Up @@ -492,6 +512,8 @@ public string ExpandKernelName(string name)
return "Mosa.CoolWorld.x86";
case "testworld":
return "Mosa.TestWorld.x86";
case "unittests":
return "Mosa.UnitTests.x86";
}
return name;
}
Expand Down
3 changes: 3 additions & 0 deletions Source/Mosa.UnitTests.x86/Boot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public static void Main()

private static void Setup()
{
Logger.Log("Initialize Kernel");

IDT.SetInterruptHandler(null);
Panic.Setup();
Debugger.Setup(Serial.COM2);
Expand All @@ -41,6 +43,7 @@ private static void Setup()
// ThreadScheduler.Setup();

//Runtime.Internal.Setup();
Logger.Log("Kernel initialized");
}

public static void EnterTestReadyLoop()
Expand Down
3 changes: 3 additions & 0 deletions Source/Mosa.Utility.Launcher/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ public bool AllOptimizationsOff
[Option("multiboot-none")]
public bool MultiBootNone { set { MultibootSpecification = MultibootSpecification.None; } }

[Option("no-display")]
public bool NoDisplay { get; set; }

[Option("platform")]
public PlatformType PlatformType { get; set; }

Expand Down
6 changes: 4 additions & 2 deletions Source/Mosa.Utility.Launcher/Starter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ private Process LaunchQemu(bool getOutput)

//arg = arg + " -vga vmware";

// We need as lest 2 COM Ports:
if (Options.NoDisplay)
arg += " -display none";

// We need as least 2 COM Ports:
// COM1 = Kernel log
// COM2 = MosaDebugger

arg = arg + " -serial tcp::1240,server,nowait"; // TODO: Redirect to file
arg = arg + " -serial null"; // TODO: Redirect to file

if (Options.SerialConnectionOption == SerialConnectionOption.Pipe)
{
Expand Down
15 changes: 14 additions & 1 deletion Source/Mosa.Utility.UnitTests/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
// Copyright (c) MOSA Project. Licensed under the New BSD License.

using System;

namespace Mosa.Utility.UnitTests
{
internal static class Program
{
private static void Main()
{
UnitTestSystem.Start();
try
{
if (UnitTestSystem.Start() == 0)
Environment.Exit(0);
else
Environment.Exit(1);
}
catch (Exception ex)
{
Console.WriteLine(ex);
Environment.Exit(1);
}
}
}
}
27 changes: 20 additions & 7 deletions Source/Mosa.Utility.UnitTests/UnitTestEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ public UnitTestEngine()
PlugKorlib = true
};

// Ensure NoDisplay=true on appveyor! Otherwise, test will fail
// (appveyor cannot open a display)
Options.NoDisplay = true;

AppLocations = new AppLocations();

AppLocations.FindApplications();
Expand Down Expand Up @@ -290,8 +294,10 @@ public bool ConnectToDebugEngine()
DebugServerEngine.SetGlobalDispatch(GlobalDispatch);
}

for (int attempt = 0; attempt < 25; attempt++)
for (int attempt = 0; attempt < 100; attempt++)
{
Thread.Sleep(100);

if (DebugServerEngine.IsConnected)
return true;

Expand All @@ -302,10 +308,10 @@ public bool ConnectToDebugEngine()
catch
{
}

Thread.Sleep(50);
}

Console.Write("Unable to connect to DebugEngine");

return false;
}

Expand Down Expand Up @@ -339,15 +345,15 @@ private void KillVirtualMachine()

private bool WaitForReady()
{
for (int attempt = 0; attempt < 400; attempt++)
for (int attempt = 0; attempt < 100; attempt++)
{
if (Ready)
{
LastResponse = (int)StopWatch.ElapsedMilliseconds;
return true;
}

Thread.Sleep(10);
Thread.Sleep(100);
}

return false;
Expand Down Expand Up @@ -511,16 +517,23 @@ private void MessageCallBack(DebugMessage response)

void IBuilderEvent.NewStatus(string status)
{
//Console.WriteLine(status);
Console.WriteLine(status);
}

private DateTime UpdateProgressLastWrittenDate;
void IBuilderEvent.UpdateProgress(int total, int at)
{
var ts = DateTime.Now - UpdateProgressLastWrittenDate;
if (ts.TotalSeconds > 3)
{
UpdateProgressLastWrittenDate = DateTime.Now;
Console.WriteLine("{0} / {1}", at, total);
}
}

void IStarterEvent.NewStatus(string status)
{
//Console.WriteLine(status);
Console.WriteLine(status);
}

void IDisposable.Dispose()
Expand Down
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ for:

after_build:
- ps: ./mosactl.ps1 test
- ps: ./mosactl.ps1 unittest
- cmd: ISCC.exe Source/Inno-Setup-Script/Mosa-Installer.iss

build_script:
Expand Down Expand Up @@ -76,4 +77,4 @@ for:
# - sh: echo $APPVEYOR_BUILD_FOLDER; ls -l $APPVEYOR_BUILD_FOLDER;
# - sh: echo $PWD; ls -l; ls -l $PWD ; echo blubb; ls -l $PWD/Ressources; ls -l $PWD/Ressources/docker-integration
- sh: echo UID "$UID"
- sh: docker run --name MOSA -v $APPVEYOR_BUILD_FOLDER:/home/appveyor seblon/mosa-docker-integration /bin/bash -c "useradd -m -u $UID appveyor && su appveyor -- -c 'cd /home/appveyor && chmod +x mosactl && ./mosactl test'"
- sh: docker run --name MOSA -v $APPVEYOR_BUILD_FOLDER:/home/appveyor seblon/mosa-docker-integration /bin/bash -c "useradd -m -u $UID appveyor && su appveyor -- -c 'cd /home/appveyor && chmod +x mosactl && ./mosactl test && ./mosactl unittest'"
2 changes: 1 addition & 1 deletion mosactl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [ -f $tmpScript ]; then
fi

if [ ! -f $rdir/bin/Mosa.Tool.Mosactl.exe ]; then
$rdir/Tools/nuget/nuget.exe restore Source/Mosa.Tool.Mosactl.sln
mono $rdir/Tools/nuget/nuget.exe restore Source/Mosa.Tool.Mosactl.sln
msbuild $rdir/Source/Mosa.Tool.Mosactl.sln
fi

Expand Down

0 comments on commit 8ead08e

Please sign in to comment.