Skip to content
Permalink
Browse files

Added unit tests to appveyor

  • Loading branch information...
Arakis committed Feb 10, 2019
1 parent 84252cd commit d02d9cd8a07c69d7c7e3571255b8edbef8e3be54
@@ -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
@@ -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;
@@ -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"))
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";
@@ -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;
}
@@ -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);
@@ -41,6 +43,7 @@ private static void Setup()
// ThreadScheduler.Setup();

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

public static void EnterTestReadyLoop()
@@ -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; }

@@ -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)
{
@@ -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);
}
}
}
}
@@ -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();
@@ -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;

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

Thread.Sleep(50);
}

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

return false;
}

@@ -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;
@@ -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()
@@ -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:
@@ -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'"
@@ -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

0 comments on commit d02d9cd

Please sign in to comment.
You can’t perform that action at this time.