tests: add simple networking test

Just a test that pings one machine from another.
This commit is contained in:
Emery Hemingway 2020-11-10 16:39:34 +01:00
parent 7822090e58
commit 1dad7fa174
2 changed files with 46 additions and 0 deletions

View File

@ -11,6 +11,7 @@ let
./bash.nix
./hello.nix
./log.nix
./networking.nix
./solo5/multi.nix
./vmm_x86.nix
./x86.nix

45
tests/networking.nix Normal file
View File

@ -0,0 +1,45 @@
{
name = "networking";
nodes = {
a = { pkgs, ... }: { imports = [ ../nixos-modules/hardware.nix ]; };
b = { config, pkgs, ... }: {
imports = [ ../nixos-modules/hardware.nix ];
networking.interfaces.eth1.genode.stack = null;
genode.init.children.ping = {
inputs = with pkgs.genodePackages; [ ping ];
configFile = let
ip = builtins.head config.networking.interfaces.eth1.ipv4.addresses;
in pkgs.writeText "ping.dhall" ''
let Genode = env:DHALL_GENODE
let Init = Genode.Init
let Child = Init.Child
in Child.flat
Child.Attributes::{
, binary = "ping"
, resources = Init.Resources::{ ram = Genode.units.MiB 8 }
, routes = [ Init.ServiceRoute.child "Nic" "eth1.driver" ]
, config = Init.Config::{
, attributes = toMap
{ interface = "${ip.address}/${toString ip.prefixLength}"
, dst_ip = "192.168.1.1"
, period_sec = "1"
, count = "10"
, verbose = "yes"
}
}
}
'';
};
};
};
testScript = ''
start_all()
b.wait_until_serial_output('child "ping" exited with exit value 0')
'';
}