2
0
Fork 0
genodepkgs/tests/hello.nix

78 lines
2.6 KiB
Nix

{
name = "hello";
machine = { pkgs, ... }:
let
hello = pkgs.stdenv.mkDerivation {
name = "hello";
dontUnpack = true;
buildPhase = ''
cat > hello.c << EOF
#include <stdio.h>
int main(int argc, char **argv) { printf("hello world!\n"); return 0; }
EOF
$CC hello.c -o hello
'';
installPhase = "install -Dt $out/bin hello";
};
in {
genode.init.children.hello = {
configFile = pkgs.writeText "hello.dhall" ''
let Genode = env:DHALL_GENODE
let Init = Genode.Init
let Child = Init.Child
in Child.flat
Child.Attributes::{
, binary = "${hello}/bin/hello"
, exitPropagate = True
, resources = Genode.Init.Resources::{
, caps = 500
, ram = Genode.units.MiB 10
}
, config = Init.Config::{
, content =
let XML = Genode.Prelude.XML
in [ XML.leaf
{ name = "libc"
, attributes = toMap
{ stdin = "/dev/null"
, stdout = "/dev/log"
, stderr = "/dev/log"
}
}
, XML.element
{ name = "vfs"
, attributes = XML.emptyAttributes
, content =
let dir =
λ(name : Text)
λ(content : List XML.Type)
XML.element
{ name = "dir"
, content
, attributes = toMap { name }
}
let leaf =
λ(name : Text)
XML.leaf
{ name, attributes = XML.emptyAttributes }
in [ dir "dev" [ leaf "log", leaf "null" ] ]
}
]
}
}
'';
};
};
testScript = ''
start_all()
machine.wait_until_serial_output("child \"init\" exited with exit value 0")
'';
}