Skip to content

Commit

Permalink
Merge pull request #593 from Arakis/033.2-test-integration
Browse files Browse the repository at this point in the history
Integrate Linux build in Pipeline. Integrate Tests in Pipeline.
  • Loading branch information
tgiphil committed Feb 9, 2019
2 parents 4ddb3b9 + 89450d3 commit 1f87304
Show file tree
Hide file tree
Showing 16 changed files with 235 additions and 86 deletions.
19 changes: 19 additions & 0 deletions Ressources/docker-integration/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM debian:stretch

RUN apt-get update && apt-get upgrade -y

RUN apt-get install -y apt-transport-https dirmngr \
&& apt-key adv --no-tty --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \
&& echo "deb https://download.mono-project.com/repo/debian stable-stretch main" | tee /etc/apt/sources.list.d/mono-official-stable.list \
&& apt-get update

RUN apt-get install -y mono-devel

RUN apt-get install -y qemu-system-x86

RUN apt-get install -y git wget

#RUN useradd -m mosa

#USER mosa
#WORKDIR /home/mosa
13 changes: 13 additions & 0 deletions Ressources/docker-integration/publish
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

NAME=mosa-debian-integration
IMAGE=seblon/mosa-debian-integration

#docker build . -t mosa/$NAME

docker rm -f $NAME

docker run -it --name $NAME -v ${PWD}/start:/home/mosa/start $IMAGE /bin/bash -c /home/mosa/start
#docker run -it --name $NAME -v ${PWD}/start:/home/mosa/start mosa/$NAME /bin/bash


5 changes: 5 additions & 0 deletions Ressources/docker-integration/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

git clone https://github.com/mosa/MOSA-Project.git
cd MOSA-Project
./mosactl test
2 changes: 1 addition & 1 deletion Source/Mosa.CoolWorld.x86/Boot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public static void Main()

IDT.SetInterruptHandler(manager.ProcessInterrupt);

Logger.Log("<TEST:PASSED:Boot.Main>");
Logger.Log("<SELFTEST:PASSED>");

manager.Start();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.HelloWorld.x86/Boot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public static void Main()

Console.Goto(12, 0);

Logger.Log("<TEST:PASSED:Boot.Main>");
Logger.Log("<SELFTEST:PASSED>");

while (true)
{
Expand Down
4 changes: 3 additions & 1 deletion Source/Mosa.Kernel.x86/Kernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public static class Kernel
{
public static void Setup()
{
Logger.Log("Initialize Kernel");

// Initialize GDT before IDT, because IDT Entries requies a valid Segment Selector
// This never happend before, because on fast computers GDT.Setup() was called
// before a Interrupt,for example clock, got triggered.
Expand All @@ -38,7 +40,7 @@ public static void Setup()
SmbiosManager.Setup();
ConsoleManager.Setup();

Logger.Log("Kernel Setup finished");
Logger.Log("Kernel initialized");
}
}
}
171 changes: 114 additions & 57 deletions Source/Mosa.Tool.Mosactl/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public void Run(List<string> args)
if (args.Count == 0)
{
PrintHelp("usage");
Environment.Exit(1);
return;
}

Expand All @@ -95,21 +96,26 @@ public void Run(List<string> args)
switch (args[0])
{
case "tools":
TaskTools(CheckType.force);
if (!TaskTools(CheckType.force))
Environment.Exit(1);
break;
case "runtime":
TaskRuntime(CheckType.force);
if (!TaskRuntime(CheckType.force))
Environment.Exit(1);
break;
case "net":
case "dotnet":
TaskCILBuild(CheckType.force, args);
if (!TaskCILBuild(CheckType.force, args))
Environment.Exit(1);
break;
case "bin":
case "binary":
TaskBinaryBuild(CheckType.force, args);
if (!TaskBinaryBuild(CheckType.force, args))
Environment.Exit(1);
break;
case "run":
TaskRun(args);
if (!TaskRun(args))
Environment.Exit(1);
break;
case "test":
if (!TaskTest(args))
Expand All @@ -118,10 +124,15 @@ public void Run(List<string> args)
case "debug":
TaskDebug(args);
break;
case "help":
PrintHelp("usage");
break;
}
}

private string OsName = "HelloWorld";
private string OsName = "all";

private string[] OsNames = new string[] { "helloworld", "coolworld" };

private void PrintHelp(string name)
{
Expand All @@ -131,14 +142,16 @@ private void PrintHelp(string name)
}
}

public void TaskCILBuild(CheckType ct, List<string> args)
public bool TaskCILBuild(CheckType ct, List<string> args)
{
TaskRuntime(CheckType.changed);

if (!File.Exists(GetEnv(ExpandKernelBinPath(OsName) + ".exe")) || ct == CheckType.force)
{
CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), ExpandKernelCsProjPath(OsName));
if (!CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), ExpandKernelCsProjPath(OsName), "-verbosity:minimal"))
return false;
}
return true;
}

private bool CallMonoProcess(string workdir, string cmd, params string[] args)
Expand All @@ -160,37 +173,47 @@ private bool CallProcess(string workdir, string cmd, params string[] args)
var proc = Process.Start(start);
proc.WaitForExit();

if (proc.ExitCode > 0)
{
Console.WriteLine("Exit Code " + proc.ExitCode);
}

return proc.ExitCode == 0;
}

public void TaskBinaryBuild(CheckType ct, List<string> args)
public bool TaskBinaryBuild(CheckType ct, List<string> args)
{
TaskTools(CheckType.changed);
TaskCILBuild(CheckType.changed, args);
if (!TaskTools(CheckType.changed))
return false;
if (!TaskCILBuild(CheckType.changed, args))
return false;

if (!File.Exists(ExpandKernelBinPath(OsName) + ".bin") || ct == CheckType.force)
{
var compilerArgs = new List<string>() {
"-o",
ExpandKernelBinPath(OsName)+".bin",
"-a",
"x86",
"--mboot",
"v1",
"--map",
ExpandKernelBinPath(OsName)+".map",
"--debug-info",
ExpandKernelBinPath(OsName)+".debug",
"--base-address",
"0x00500000",
"mscorlib.dll",
"Mosa.Plug.Korlib.dll",
"Mosa.Plug.Korlib.x86.dll",
ExpandKernelBinPath(OsName)+".exe"
};
"-o",
ExpandKernelBinPath(OsName)+".bin",
"-a",
"x86",
"--mboot",
"v1",
"--map",
ExpandKernelBinPath(OsName)+".map",
"--debug-info",
ExpandKernelBinPath(OsName)+".debug",
"--base-address",
"0x00500000",
"mscorlib.dll",
"Mosa.Plug.Korlib.dll",
"Mosa.Plug.Korlib.x86.dll",
ExpandKernelBinPath(OsName)+".exe"
};

CallMonoProcess(BinDir, "Mosa.Tool.Compiler.exe", compilerArgs.ToArray());
if (!CallMonoProcess(BinDir, "Mosa.Tool.Compiler.exe", compilerArgs.ToArray()))
return false;
}

return true;
}

private class PlattformAppCall
Expand Down Expand Up @@ -231,29 +254,49 @@ public void TaskBuild(List<string> args)
TaskDiskBuild();
}

public void TaskRun(List<string> args)
public bool TaskRun(List<string> args)
{
var ct = args.Contains("--build") ? CheckType.force : CheckType.changed;
TaskCILBuild(ct, args);
TaskBinaryBuild(ct, args);
if (!TaskCILBuild(ct, args))
return false;
if (!TaskBinaryBuild(ct, args))
return false;

if (!CallQemu(false, null))
return false;

CallQemu(false, null);
return true;
}

public bool TaskTestAll(List<string> args)
{
foreach (var osName in OsNames)
if (!CallProcess(BinDir, GetEnv("${MOSA_BIN}/Mosa.Tool.Mosactl.exe"), "test", osName))
return false;

return true;
}

public bool TaskTest(List<string> args)
{
TaskCILBuild(CheckType.changed, args);
TaskBinaryBuild(CheckType.changed, args);
if (OsName == "all")
return TaskTestAll(args);

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

var testSuccess = false;
CallQemu(true, (line, proc) =>
{
if (line == "<TEST:PASSED:Boot.Main>")
{
testSuccess = true;
proc.Kill();
}
});
if (!CallQemu(true, (line, proc) =>
{
if (line == "<SELFTEST:PASSED>")
{
testSuccess = true;
proc.Kill();
}
}))
return false;

if (testSuccess)
{
Expand Down Expand Up @@ -319,7 +362,8 @@ private bool CallQemu(bool nographic, Action<string, Process> OnKernelLog)
}
else
{
sb.Append(buf[0]);
if (buf[0] != '\r')
sb.Append(buf[0]);
}
}
Expand All @@ -340,10 +384,11 @@ private bool CallQemu(bool nographic, Action<string, Process> OnKernelLog)
th2.Start();
}


p.WaitForExit();

return true;
Console.WriteLine("Qemu exit code " + p.ExitCode);

return p.ExitCode == 0 || p.ExitCode == 137 || p.ExitCode == -1;
}

public void TaskDebug(List<string> args)
Expand Down Expand Up @@ -393,29 +438,41 @@ private void GenerateGDBFile()
CallProcess(BinDir, "chmod", "+x", gdbqemu);
}

public void TaskTools(CheckType ct)
public bool TaskTools(CheckType ct)
{
var exists = File.Exists(GetEnv("${MOSA_BIN}/Mosa.Tool.Compiler.exe"));
if (!exists || ct == CheckType.force)
{
CallMonoProcess(SourceDir, GetEnv("MOSA_NUGET"), "restore", "Mosa.sln");
CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Tool.Compiler/Mosa.Tool.Compiler.csproj");
CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Tool.GDBDebugger/Mosa.Tool.GDBDebugger.csproj");
if (!CallMonoProcess(SourceDir, GetEnv("MOSA_NUGET"), "restore", "Mosa.sln"))
return false;
if (!CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Tool.Compiler/Mosa.Tool.Compiler.csproj"))
return false;
if (!CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Tool.GDBDebugger/Mosa.Tool.GDBDebugger.csproj"))
return false;
}

return true;
}

public void TaskRuntime(CheckType ct)
public bool TaskRuntime(CheckType ct)
{
var exists = File.Exists(GetEnv("${MOSA_BIN}/Mosa.Plug.Korlib.dll"));
if (!exists || ct == CheckType.force)
{
CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Runtime.x86/Mosa.Runtime.x86.csproj");
CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Runtime.x64/Mosa.Runtime.x64.csproj");
CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Korlib/Mosa.Korlib.csproj");
CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Plug.Korlib/Mosa.Plug.Korlib.csproj");
CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Plug.Korlib.x86/Mosa.Plug.Korlib.x86.csproj");
CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Plug.Korlib.x64/Mosa.Plug.Korlib.x64.csproj");
if (!CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Runtime.x86/Mosa.Runtime.x86.csproj"))
return false;
if (!CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Runtime.x64/Mosa.Runtime.x64.csproj"))
return false;
if (!CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Korlib/Mosa.Korlib.csproj"))
return false;
if (!CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Plug.Korlib/Mosa.Plug.Korlib.csproj"))
return false;
if (!CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Plug.Korlib.x86/Mosa.Plug.Korlib.x86.csproj"))
return false;
if (!CallProcess(SourceDir, GetEnv("MOSA_MSBUILD"), "Mosa.Plug.Korlib.x64/Mosa.Plug.Korlib.x64.csproj"))
return false;
}
return true;
}

public enum CheckType
Expand Down
Binary file added Tools/qemu/kvmvapic.bin
Binary file not shown.
Binary file added Tools/qemu/linuxboot.bin
Binary file not shown.
Binary file added Tools/qemu/linuxboot_dma.bin
Binary file not shown.
Binary file added Tools/qemu/multiboot.bin
Binary file not shown.
Binary file added Tools/qemu/sgabios.bin
Binary file not shown.

0 comments on commit 1f87304

Please sign in to comment.