test/posix: convert to bash script
This commit is contained in:
parent
7dc432ce33
commit
46c6561302
|
@ -8,92 +8,113 @@ let Prelude = Genode.Prelude
|
||||||
|
|
||||||
let XML = Prelude.XML
|
let XML = Prelude.XML
|
||||||
|
|
||||||
let Child = Genode.Init.Child
|
let Init = Genode.Init
|
||||||
|
|
||||||
let toChild =
|
let Child = Init.Child
|
||||||
λ(binary : Text)
|
|
||||||
→ λ(args : List Text)
|
in λ(params : { bash : Text, coreutils : Text, script : Text })
|
||||||
→ { mapKey = binary
|
→ let init =
|
||||||
, mapValue =
|
Init::{
|
||||||
Child.flat
|
, verbose = True
|
||||||
Child.Attributes::{
|
, routes =
|
||||||
, binary = binary
|
[ Init.ServiceRoute.parent "Timer"
|
||||||
, exitPropagate = True
|
, Init.ServiceRoute.parent "Rtc"
|
||||||
, resources = Genode.Init.Resources::{
|
]
|
||||||
, caps = 256
|
, children = toMap
|
||||||
, ram = Genode.units.MiB 4
|
{ 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
|
in Test::{ children = Test.initToChildren init }
|
||||||
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"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,10 +3,32 @@
|
||||||
{ testEnv, pkgs, legacyPackages, ... }:
|
{ testEnv, pkgs, legacyPackages, ... }:
|
||||||
with pkgs;
|
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";
|
name = "posix";
|
||||||
testConfig = ./posix.dhall;
|
testConfig = ''
|
||||||
testInputs = map pkgs.genodeSources.depot [ "libc" "posix" ]
|
${
|
||||||
++ (with legacyPackages; [ coreutils hello ]);
|
./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 ];
|
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue