~ehmry/genodepkgs

ref: staging genodepkgs/tests/networking.nix -rw-r--r-- 1.3 KiB
7f414b17Emery Hemingway WiP! lighttpd a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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')
  '';
}