2
0
Fork 0

tests: convert posix test to nixos-modules

This commit is contained in:
Ehmry - 2020-11-07 20:23:14 +01:00
parent 69a72cac30
commit e6c46f2e15
3 changed files with 39 additions and 46 deletions

View File

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

View File

@ -1,6 +1,4 @@
let Test = ./test.dhall ? env:DHALL_GENODE_TEST let Genode = env:DHALL_GENODE
let Genode = Test.Genode
let Prelude = Genode.Prelude let Prelude = Genode.Prelude
@ -31,19 +29,22 @@ in λ(params : { bash : Text, coreutils : Text, script : Text }) →
<dir name="dev"> <log name="stdout" label="stdout"/> <log name="stderr" label="stderr"/> <null/> <pipe/> <rtc/> <zero/> </dir> <dir name="dev"> <log name="stdout" label="stdout"/> <log name="stderr" label="stderr"/> <null/> <pipe/> <rtc/> <zero/> </dir>
<dir name="usr"><dir name="bin"><symlink name="env" target="${params.coreutils}/bin/env"/></dir></dir> <dir name="usr"><dir name="bin"><symlink name="env" target="${params.coreutils}/bin/env"/></dir></dir>
<dir name="tmp"><ram/></dir> <dir name="tmp"><ram/></dir>
<dir name="nix"><fs label="nix" root="nix"/></dir> <dir name="nix"><dir name="store"><fs label="nix-store"/></dir></dir>
</vfs> </vfs>
'' ''
] ]
, policies = , policies =
[ Init.Config.Policy::{ [ Init.Config.Policy::{
, service = "File_system" , service = "File_system"
, label = , label = Init.LabelSelector.prefix "shell"
Init.LabelSelector.Type.Partial
{ prefix = Some "shell", suffix = None Text }
, attributes = toMap , attributes = toMap
{ root = "/", writeable = "yes" } { root = "/", writeable = "yes" }
} }
, Init.Config.Policy::{
, service = "File_system"
, label = Init.LabelSelector.prefix "vfs_rom"
, attributes = toMap { root = "/" }
}
] ]
} }
, provides = [ "File_system" ] , provides = [ "File_system" ]
@ -58,7 +59,7 @@ in λ(params : { bash : Text, coreutils : Text, script : Text }) →
Init.ServiceRoute.parent Init.ServiceRoute.parent
[ "File_system", "Rtc" ] [ "File_system", "Rtc" ]
} }
, store_rom = , vfs_rom =
Child.flat Child.flat
Child.Attributes::{ Child.Attributes::{
, binary = "cached_fs_rom" , binary = "cached_fs_rom"
@ -67,12 +68,6 @@ in λ(params : { bash : Text, coreutils : Text, script : Text }) →
, caps = 256 , caps = 256
, ram = Genode.units.MiB 4 , ram = Genode.units.MiB 4
} }
, routes =
[ Init.ServiceRoute.parentLabel
"File_system"
(None Text)
(Some "nix")
]
} }
, shell = , shell =
Child.flat Child.flat
@ -113,7 +108,7 @@ in λ(params : { bash : Text, coreutils : Text, script : Text }) →
} }
, route = , route =
Init.Route.Type.Child Init.Route.Type.Child
{ name = "store_rom" { name = "vfs_rom"
, label = None Text , label = None Text
, diag = None Bool , diag = None Bool
} }
@ -123,4 +118,4 @@ in λ(params : { bash : Text, coreutils : Text, script : Text }) →
} }
} }
in Test::{ children = Test.initToChildren init } in Init.toChild init Init.Attributes::{=}

View File

@ -1,33 +1,30 @@
{ pkgs, legacyPackages, ... }: {
with pkgs;
let
inherit (legacyPackages) bash coreutils;
script = with legacyPackages;
writeTextFile {
name = "posix.sh";
text = ''
export PATH=${
lib.makeSearchPathOutput "bin" "bin"
(with legacyPackages; [ bash hello coreutils ])
}
set -v
time ls -lR /nix
sleep 1
hello -v
sleep 1
uname -a
'';
};
in rec {
name = "posix"; name = "posix";
machine = { machine = { pkgs, ... }: {
config = '' genode.init.children.posix = with pkgs;
${ let
./posix.dhall script = writeTextFile {
} { bash = \"${bash}\", coreutils = \"${coreutils}\", script = \"${script}\" }''; name = "posix.sh";
inputs = map pkgs.genodeSources.depot [ "libc" "posix" "vfs_pipe" "vfs" ] text = ''
++ [ bash ]; export PATH=${
extraPaths = [ script ] ++ (with legacyPackages; [ coreutils hello ]); lib.makeSearchPathOutput "bin" "bin" [ bash hello coreutils ]
}
set -v
time ls -lR /nix
sleep 1
hello -v
sleep 1
uname -a
'';
};
in {
configFile = writeText "posix.child.dhall" ''
${
./posix.dhall
} { bash = "${bash}", coreutils = "${coreutils}", script = "${script}" }
'';
inputs = [ bash hello coreutils ]
++ (with genodePackages; [ cached_fs_rom libc posix vfs vfs_pipe ]);
};
}; };
} }