2
0
Fork 0

tests: add Bash test

Test Bash and Coretuils from the Genode Labs ports.
This commit is contained in:
Ehmry - 2020-11-08 17:25:35 +01:00
parent a1f9effb3c
commit a2a152b68a
6 changed files with 219 additions and 1 deletions

View File

@ -301,7 +301,7 @@ let
in makePackages // depotPackages // {
genodeSources = genodeSources // {
inherit buildUpstream buildDepot genodeBase ports specs toolchain;
inherit arch buildUpstream buildDepot genodeBase ports specs toolchain;
};
base-hw-pc = buildUpstream {

View File

@ -21,8 +21,26 @@ in {
acpi_drv = { };
bash = {
enableParallelBuilding = false;
nativeBuildInputs = with buildPackages; [ autoconf ];
portInputs = with ports; [ bash libc ];
postInstall = ''
find depot/genodelabs/bin/ -name '*.tar' -exec tar xf {} -C $out \;
rm "''${!outputBin}/bin/bashbug"
'';
};
cached_fs_rom.patches = [ ./cached_fs_rom.patch ];
coreutils = {
enableParallelBuilding = false;
portInputs = with ports; [ coreutils libc ];
postInstall = ''
find depot/genodelabs/bin/ -name '*.tar' -exec tar xf {} -C $out \;
'';
};
fb_sdl = with buildPackages; {
nativeBuildInputs = [ pkgconfig ];
buildInputs = [ SDL ];

View File

@ -5,10 +5,15 @@
with pkgs;
{
bash.hash = "sha256-Se03Eyh8grk+QGAXLGoig7oXqmHtAwtHJX54fCVHw+8=";
binutils = {
hash = "sha256-ERzYT3TjbK3fzRVN1UE7RM6XiPPeMKzkeulKx5IQa2o=";
nativeBuildInputs = [ autoconf ];
};
coreutils.hash = "sha256-ZVlFfLghHcXxwwRsN5xw2bVdIvvXoCNj2oZniOlSXrg=";
dde_bsd.hash = "sha256-/n9aHPU6/+AgRSyFD545p3BT63n3myymez1tIRhJisA=";
dde_ipxe.hash = "sha256-NJ129+DkxFg1fFHJBABBFRRjqEVNSz6v2hEB80AuEM4=";
dde_linux.hash = "sha256-xHAgeKfArgMGKCGHi0762qkUcY97vbiAQYjM/ZRXCes=";

170
tests/bash.dhall Normal file
View File

@ -0,0 +1,170 @@
let Genode = env:DHALL_GENODE
let Prelude = Genode.Prelude
let XML = Prelude.XML
let VFS = Genode.VFS
let Init = Genode.Init
let Child = Init.Child
in λ(params : { bash : Text, coreutils : Text }) →
let init =
Init::{
, verbose = True
, routes =
[ Init.ServiceRoute.parent "Timer"
, Init.ServiceRoute.parent "Rtc"
]
, children = toMap
{ vfs =
Child.flat
Child.Attributes::{
, binary = "vfs"
, 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" ]
, config = Init.Config::{
, content =
[ VFS.vfs
[ VFS.dir
"dev"
[ VFS.dir "pipes" [ VFS.leaf "pipe" ]
, VFS.leaf "log"
, VFS.leaf "null"
, VFS.leaf "rtc"
, VFS.leaf "zero"
]
, VFS.dir
"usr"
[ VFS.dir
"bin"
[ VFS.symlink
"env"
"${params.coreutils}/bin/env"
]
]
, VFS.dir "ram" [ VFS.leaf "ram" ]
, VFS.dir
"nix"
[ VFS.dir
"store"
[ VFS.fs VFS.FS::{ label = "nix-store" } ]
]
, VFS.inline
"script.sh"
''
bash --version
bash -c "bash --version"
''
]
]
, policies =
[ Init.Config.Policy::{
, service = "File_system"
, label = Init.LabelSelector.prefix "shell"
, attributes = toMap
{ root = "/", writeable = "yes" }
}
, Init.Config.Policy::{
, service = "File_system"
, label = Init.LabelSelector.prefix "vfs_rom"
, attributes = toMap { root = "/" }
}
]
}
}
, vfs_rom =
Child.flat
Child.Attributes::{
, binary = "cached_fs_rom"
, provides = [ "ROM" ]
, resources = Init.Resources::{
, caps = 256
, ram = Genode.units.MiB 32
}
, config = Init.Config::{
, policies =
[ Init.Config.Policy::{
, service = "ROM"
, label = Init.LabelSelector.prefix "shell"
}
]
}
}
, shell =
Child.flat
Child.Attributes::{
, binary = "${params.bash}/bin/bash"
, exitPropagate = True
, resources = Genode.Init.Resources::{
, caps = 256
, ram = Genode.units.MiB 8
}
, routes =
Prelude.List.map
Text
Init.ServiceRoute.Type
( λ(label : Text) →
Init.ServiceRoute.parentLabel
"ROM"
(Some label)
(Some label)
)
[ "libc.lib.so"
, "libm.lib.so"
, "posix.lib.so"
, "vfs.lib.so"
]
, config = Genode.Init.Config::{
, attributes = toMap { ld_verbose = "true" }
, content =
let env =
λ(key : Text) →
λ(value : Text) →
XML.leaf
{ name = "env"
, attributes = toMap { key, value }
}
let arg =
λ(value : Text) →
XML.leaf
{ name = "arg"
, attributes = toMap { value }
}
in [ XML.leaf
{ name = "libc"
, attributes = toMap
{ stdin = "/dev/null"
, stdout = "/dev/log"
, stderr = "/dev/log"
, pipe = "/dev/pipe"
, rtc = "/dev/rtc"
}
}
, VFS.vfs [ VFS.fs VFS.FS::{ label = "root" } ]
, env "TERM" "screen"
, env
"PATH"
"${params.coreutils}/bin:${params.bash}/bin"
, arg "bash"
, arg "/script.sh"
]
}
}
}
}
in Init.toChild init Init.Attributes::{=}

24
tests/bash.nix Normal file
View File

@ -0,0 +1,24 @@
{
name = "bash";
machine = { pkgs, ... }: {
genode.init.children.bash = {
configFile = pkgs.writeText "bash.child.dhall" ''
${
./bash.dhall
} { bash = "${pkgs.genodePackages.bash}", coreutils = "${pkgs.coreutils}" }
'';
inputs = with pkgs.genodePackages; [
bash
cached_fs_rom
libc
posix
vfs
vfs_pipe
];
};
};
testScript = ''
start_all()
machine.wait_until_serial_output('child "bash" exited with exit value 0')
'';
}

View File

@ -8,6 +8,7 @@ let
testingPython = import ./lib/testing-python.nix;
testSpecs = map (p: import p) [
./bash.nix
./hello.nix
./log.nix
./solo5/multi.nix