2
0
Fork 0

test/posix: convert to bash script

This commit is contained in:
Ehmry - 2020-05-29 22:04:45 +05:30
parent 7dc432ce33
commit 46c6561302
2 changed files with 133 additions and 90 deletions

View File

@ -8,92 +8,113 @@ let Prelude = Genode.Prelude
let XML = Prelude.XML
let Child = Genode.Init.Child
let Init = Genode.Init
let toChild =
λ(binary : Text)
→ λ(args : List Text)
→ { mapKey = binary
, mapValue =
Child.flat
Child.Attributes::{
, binary = binary
, exitPropagate = True
, resources = Genode.Init.Resources::{
, caps = 256
, ram = Genode.units.MiB 4
let Child = Init.Child
in λ(params : { bash : Text, coreutils : Text, script : Text })
→ let init =
Init::{
, verbose = True
, routes =
[ Init.ServiceRoute.parent "Timer"
, Init.ServiceRoute.parent "Rtc"
]
, children = toMap
{ vfs =
Child.flat
Child.Attributes::{
, binary = "vfs"
, config = Init.Config::{
, content =
[ Prelude.XML.text
''
<vfs>
<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="tmp"><ram/></dir>
<dir name="nix"><fs label="nix" root="nix"/></dir>
</vfs>
<default-policy root="/" writeable="yes"/>
''
]
}
, provides = [ "File_system" ]
, resources = Genode.Init.Resources::{
, caps = 256
, ram = Genode.units.MiB 8
}
, routes =
Prelude.List.map
Text
Init.ServiceRoute.Type
Init.ServiceRoute.parent
[ "File_system", "Rtc" ]
}
, store_rom =
Child.flat
Child.Attributes::{
, binary = "cached_fs_rom"
, provides = [ "ROM" ]
, resources = Init.Resources::{
, caps = 256
, ram = Genode.units.MiB 4
}
, routes =
[ Init.ServiceRoute.parentLabel
"File_system"
(None Text)
(Some "nix")
]
}
, shell =
Child.flat
Child.Attributes::{
, binary = "bash"
, config = Genode.Init.Config::{
, content =
[ Prelude.XML.text
''
<libc stdin="/dev/null" stdout="/dev/stdout" stderr="/dev/stderr" pipe="/dev/pipe" rtc="/dev/rtc"/>
<vfs> <fs/> </vfs>
''
]
# Prelude.List.map
Text
XML.Type
( λ(x : Text)
→ XML.leaf
{ name = "arg"
, attributes = toMap { value = x }
}
)
[ "bash", params.script ]
}
, exitPropagate = True
, resources = Genode.Init.Resources::{
, caps = 256
, ram = Genode.units.MiB 8
}
, routes =
[ Init.ServiceRoute.child "File_system" "vfs"
, { service =
{ name = "ROM"
, label =
Init.LabelSelector.Type.Partial
{ prefix = Some "/nix/store/"
, suffix = None Text
}
}
, route =
Init.Route.Type.Child
{ name = "store_rom"
, label = None Text
, diag = None Bool
}
}
]
}
}
, config = Genode.Init.Config::{
, content =
[ Prelude.XML.text
''
<libc stdin="/dev/null" stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc"/>
<vfs>
<dir name="dev"> <log/> <null/> <rtc/> </dir>
<dir name="testdir">
<inline name="testfile">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.
}
Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam
varius, turpis et commodo pharetra, est eros bibendum elit, nec luctus
magna felis sollicitudin mauris. Integer in mauris eu nibh euismod
gravida. Duis ac tellus et risus vulputate vehicula. Donec lobortis
risus a elit. Etiam tempor. Ut ullamcorper, ligula eu tempor congue,
eros est euismod turpis, id tincidunt sapien risus a quam. Maecenas
fermentum consequat mi. Donec fermentum. Pellentesque malesuada nulla a
mi. Duis sapien sem, aliquet nec, commodo eget, consequat quis, neque.
Aliquam faucibus, elit ut dictum aliquet, felis nisl adipiscing sapien,
sed malesuada diam lacus eget erat. Cras mollis scelerisque nunc. Nullam
arcu. Aliquam consequat. Curabitur augue lorem, dapibus quis, laoreet
et, pretium ac, nisi. Aenean magna nisl, mollis quis, molestie eu,
feugiat in, orci. In hac habitasse platea dictumst.
</inline>
</dir>
<dir name="tmp"><ram/></dir>
</vfs>
''
]
# Prelude.List.map
Text
XML.Type
( λ(x : Text)
→ XML.leaf
{ name = "arg", attributes = toMap { value = x } }
)
([ binary ] # args)
}
}
}
let f = λ(binary : Text) → toChild binary ([] : List Text)
let g = toChild
in Test::{
, children =
[ g "hello" [ "--version" ]
, g "b2sum" [ "testdir/testfile" ]
, f "date"
, f "dir"
, f "env"
, g "factor" [ "1337" ]
, g "head" [ "-n", "4", "testdir/testfile" ]
, f "id"
, g "ln" [ "-sv", "testdir/testfile", "tmp/testfile" ]
, g "ls" [ "-l", "-a", "-R" ]
, f "mktemp"
, f "mktemp"
, f "mktemp"
, f "pwd"
, g "seq" [ "3" ]
, g "tail" [ "-n", "4", "testdir/testfile" ]
, g "wc" [ "testdir/testfile" ]
, f "whoami"
]
}
in Test::{ children = Test.initToChildren init }

View File

@ -3,10 +3,32 @@
{ testEnv, pkgs, legacyPackages, ... }:
with pkgs;
testEnv.mkTest rec {
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 testEnv.mkTest rec {
name = "posix";
testConfig = ./posix.dhall;
testInputs = map pkgs.genodeSources.depot [ "libc" "posix" ]
++ (with legacyPackages; [ coreutils hello ]);
testConfig = ''
${
./posix.dhall
} { bash = \"${bash}\", coreutils = \"${coreutils}\", script = \"${script}\" }'';
testInputs = map pkgs.genodeSources.depot [ "libc" "posix" "vfs_pipe" "vfs" ]
++ [ bash ];
extraPaths = [ script ] ++ (with legacyPackages; [ coreutils hello ]);
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ];
}