Add NetworkTest

This commit is contained in:
valentinbreiz 2021-01-20 15:15:37 +01:00
parent 89c4fc2da3
commit 4872875f5b
4 changed files with 63 additions and 0 deletions

View file

@ -29,6 +29,7 @@
<ProjectReference Include="..\Kernels\Cosmos.Kernel.Tests.Fat\Cosmos.Kernel.Tests.Fat.csproj" />
<ProjectReference Include="..\Kernels\Cosmos.Kernel.Tests.IO\Cosmos.Kernel.Tests.IO.csproj" />
<ProjectReference Include="..\Kernels\GraphicTest\GraphicTest.csproj" />
<ProjectReference Include="..\Kernels\NetworkTest\NetworkTest.csproj" />
<ProjectReference Include="..\Kernels\ProcessorTests\ProcessorTests.csproj" />
<ProjectReference Include="..\Kernels\MemoryOperationsTest\MemoryOperationsTest.csproj" />
<ProjectReference Include="..\Kernels\SimpleStructsAndArraysTest\SimpleStructsAndArraysTest.csproj" />

View file

@ -31,6 +31,7 @@ namespace Cosmos.TestRunner.Full
//yield return typeof(KernelGen3.Boot);
yield return typeof(GraphicTest.Kernel);
yield return typeof(NetworkTest.Kernel);
/* Please see the notes on the kernel itself before enabling it */
//yield return typeof(ConsoleTest.Kernel);
/* This is a bit slow and works only because ring check is disabled to decide if leave it enabled */

View file

@ -0,0 +1,47 @@
using Cosmos.HAL;
using Cosmos.System.Network.Config;
using Cosmos.System.Network.IPv4;
using Cosmos.System.Network.IPv4.UDP;
using Cosmos.TestRunner;
using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
namespace NetworkTest
{
public class Kernel : Sys.Kernel
{
protected override void BeforeRun()
{
}
protected override void Run()
{
/** IPConfig Enable test **/
mDebugger.Send($"Testing IPConfig.Enable");
//get nic by name
NetworkDevice nic = NetworkDevice.GetDeviceByName("eth0");
if (Equals(nic, null))
{
mDebugger.Send($"eth0 not found.");
TestController.Failed();
}
//Enable network config
IPConfig.Enable(nic, new Address(192, 168, 1, 69), new Address(255, 255, 255, 0), new Address(192, 168, 1, 254));
Address ip = new Address(192, 168, 1, 70);
int port = 4242;
string message = "Hello from Cosmos!";
/** Udp test **/
var xClient = new UdpClient(port);
xClient.Connect(ip, port);
xClient.Send(Encoding.ASCII.GetBytes(message));
mDebugger.Send("Sent UDP packet to " + ip.ToString() + ":" + port);
xClient.Close();
TestController.Completed();
}
}
}

View file

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\source\Cosmos.Debug.Kernel\Cosmos.Debug.Kernel.csproj" />
<ProjectReference Include="..\..\..\source\Cosmos.System2\Cosmos.System2.csproj" />
<ProjectReference Include="..\..\Cosmos.TestRunner.TestController\Cosmos.TestRunner.TestController.csproj" />
</ItemGroup>
</Project>