2
0
Fork 0
Browse Source

tests: load binaries from store tarball

Remove linux tests, not compatible with cached_fs_rom.
legacyPackages
Emery Hemingway 2 years ago
parent
commit
f289a4b88f
  1. 142
      tests/block_router.dhall
  2. 20
      tests/block_router.nix
  3. 8
      tests/default.nix
  4. 20
      tests/driver-hw.nix
  5. 127
      tests/driver-linux.nix
  6. 25
      tests/driver-nova.nix
  7. 2
      tests/posix.nix
  8. 99
      tests/test-wrapper.dhall

142
tests/block_router.dhall

@ -1,142 +0,0 @@
-- SPDX-License-Identifier: CC0-1.0
let Test = ./test.dhall ? env:DHALL_GENODE_TEST
let Genode = Test.Genode
let Prelude = Genode.Prelude
let XML = Prelude.XML
let Init = Genode.Init
let Child = Init.Child
let Resources = Init.Resources
let ServiceRoute = Init.ServiceRoute
let init =
Init::{
, verbose = True
, routes =
[ ServiceRoute.parent "Timer"
, ServiceRoute.child "Block" "block_router"
]
, children =
let blockTest =
Child.flat
Child.Attributes::{
, binary = "test-block-client"
, resources = Resources::{ ram = Genode.units.MiB 5 }
}
in toMap
{ block_device =
Child.flat
Child.Attributes::{
, binary = "ram_block"
, config = Init.Config::{
, attributes = toMap
{ file = "gpt.rom", block_size = "512" }
}
, provides = [ "Block" ]
, resources = Resources::{ ram = Genode.units.MiB 8 }
}
, part_block =
Child.flat
Child.Attributes::{
, binary = "part_block"
, config = Init.Config::{
, attributes = toMap { use_gpt = "yes" }
, content =
Prelude.List.map
Natural
XML.Type
( λ(i : Natural)
→ XML.leaf
{ name = "policy"
, attributes =
let partition =
Prelude.Natural.show (i + 1)
in toMap
{ label_suffix = " ${partition}"
, partition = partition
, writeable = "yes"
}
}
)
(Prelude.Natural.enumerate 128)
# [ XML.leaf
{ name = "report"
, attributes = toMap { partitions = "yes" }
}
]
}
, resources = Resources::{ ram = Genode.units.MiB 10 }
, provides = [ "Block" ]
, routes =
[ ServiceRoute.child "Block" "block_device"
, ServiceRoute.child "Report" "block_router"
]
}
, block_router =
Child.flat
Child.Attributes::{
, binary = "block_router"
, config = Init.Config::{
, content =
[ XML.element
{ name = "policy"
, attributes = toMap
{ label_prefix = "test-part1" }
, content =
[ XML.leaf
{ name = "partition"
, attributes = toMap
{ name = "best partition ever" }
}
, XML.leaf
{ name = "partition"
, attributes = toMap
{ name = "first-test-partition"
, timeout = "2"
}
}
]
}
, XML.element
{ name = "policy"
, attributes = toMap
{ label_prefix = "test-part2" }
, content =
[ XML.leaf
{ name = "partition"
, attributes = toMap
{ type =
"24B69406-18A1-428D-908E-D21A1437122C"
}
}
]
}
]
}
, resources = Resources::{ ram = Genode.units.MiB 10 }
, provides = [ "Block", "Report" ]
, routes =
[ ServiceRoute.parent "Timer"
, ServiceRoute.child "Block" "part_block"
]
}
, test-part1 = blockTest
, test-part2 = blockTest
}
}
in Test::{
, children = Test.initToChildren init
, rom =
Genode.BootModules.toRomPaths
[ { mapKey = "gpt.rom", mapValue = "./gpt.raw" } ]
}

20
tests/block_router.nix

@ -1,20 +0,0 @@
# SPDX-License-Identifier: CC0-1.0
{ testEnv, pkgs, buildPackages, ... }:
with pkgs;
testEnv.mkTest {
name = "block_router";
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ];
testConfig = ./block_router.dhall;
testInputs =
map pkgs.genodeSources.depot [ "part_block" "ram_block" "test-block" ]
++ [ pkgs.block_router ];
testScript = ''
catch { exec dd if=/dev/zero of=gpt.raw bs=512 count=7168 }
exec ${buildPackages.gptfdisk}/bin/sgdisk -o -n 3:2048:4095 -c 3:first-test-partition -n 31:4096:6143 --typecode=31:24b69406-18a1-428d-908e-d21a1437122c gpt.raw
run_genode_until {Tests finished successfully.*\n.*Tests finished successfully.*\n} 120
'';
}

8
tests/default.nix

@ -22,12 +22,6 @@ let
'';
};
linux =
(call: ((tests call) // { block_router = call ./block_router.nix { }; }))
(import ./driver-linux.nix {
inherit apps addManifest buildPackages lib nixpkgs testPkgs;
}).callTest;
nova = (call:
((tests call) // {
driver_manager = call ./driver_manager.nix { };
@ -55,7 +49,7 @@ let
}) (builtins.attrValues tests);
in with builtins;
listToAttrs ((concatLists (map (testsToList) [ linux hw nova ]))) // {
listToAttrs ((concatLists (map (testsToList) [ hw nova ]))) // {
sotest = let
hwTests = with hw; [ multi posix x86 ];
novaTests = with nova; [ multi posix x86 vmm ];

20
tests/driver-hw.nix

@ -40,10 +40,22 @@ let
mkTest = { name ? "unamed", testScript ? defaultScript, testConfig
, testInputs ? [ ], testEnv ? { }, qemuArgs ? [ ], ... }@t:
let
manifest = lib.mergeManifests (map addManifest (with testPkgs;
[ base-hw-pc sotest-producer ]
++ map genodeSources.depot [ "init" "rtc_drv" ] ++ testInputs));
testConfig' = "${./test-wrapper.dhall} (${testConfig}) ${manifest}";
storeTarball = buildPackages.runCommand "store" { } ''
mkdir -p $out
tar cf "$out/store.tar" --absolute-names ${toString testInputs}
'';
storeManifest = lib.mergeManifests (map addManifest testInputs);
manifest = lib.mergeManifests (map addManifest
([ testPkgs.base-hw-pc testPkgs.sotest-producer storeTarball ]
++ map testPkgs.genodeSources.depot [
"init"
"rtc_drv"
"vfs"
"cached_fs_rom"
]));
testConfig' = "${
./test-wrapper.dhall
} (${testConfig}) $(stat --format '%s' ${storeTarball}/store.tar) ${storeManifest} ${manifest}";
testEnv' = {
DHALL_GENODE = "${testPkgs.dhallGenode}/source.dhall";
DHALL_GENODE_TEST = "${./test.dhall}";

127
tests/driver-linux.nix

@ -1,127 +0,0 @@
# SPDX-License-Identifier: CC0-1.0
{ addManifest, apps, buildPackages, lib, nixpkgs, testPkgs }:
let
testDriver = with buildPackages;
stdenv.mkDerivation {
name = "genode-test-driver";
preferLocalBuild = true;
buildInputs = [ makeWrapper expect ];
dontUnpack = true;
installPhase = ''
install -Dm555 ${./test-driver.exp} $out/bin/genode-test-driver
wrapProgram $out/bin/genode-test-driver \
--prefix PATH : "${lib.makeBinPath [ expect coreutils ]}"
'';
};
runTests = driver:
buildPackages.stdenv.mkDerivation {
name = "linux-" + driver.testName;
preferLocalBuild = true;
buildCommand = ''
mkdir -p $out/nix-support
${driver}/bin/genode-test-driver | tee $out/log
touch $out/nix-support
echo "report testlog $out log" >> $out/nix-support/hydra-build-products
'';
};
defaultScript =
''run_genode_until {child "init" exited with exit value 0} 120'';
mkTest = { name ? "unamed", testScript ? defaultScript, testConfig
, testInputs ? [ ], env ? { }, ... }:
with testPkgs;
let
manifest = lib.mergeManifests (map addManifest
((with testPkgs; [ base-linux init sotest-producer ] ++ testInputs)));
testConfig' = "${./test-wrapper.dhall} (${testConfig}) ${manifest}";
env' = {
DHALL_GENODE = "${testPkgs.dhallGenode}/source.dhall";
DHALL_GENODE_TEST = "${./test.dhall}";
} // env;
build = lib.linuxScript name env' testConfig';
toExports = env:
with builtins;
let
keys = attrNames env;
f = key: ''set env(${key}) "${getAttr key env}"'';
exports = map f keys;
in concatStringsSep "\n" exports;
baseSetup = ''
${toExports env'}
proc run_genode_until {{wait_for_re forever} {timeout_value 0} {running_spawn_id -1}} {
#
# If a running_spawn_id is specified, wait for the expected output
#
if {$running_spawn_id != -1} {
wait_for_output $wait_for_re $timeout_value $running_spawn_id
return
}
global image_dir spawn_id
exec sh ${build}/script
spawn ./core-linux
wait_for_output $wait_for_re $timeout_value $spawn_id
}
'';
driver = with buildPackages;
runCommand "genode-test-driver-${name}" {
buildInputs = [ makeWrapper expect ];
inherit baseSetup testScript;
preferLocalBuild = true;
testName = name;
} ''
mkdir -p $out/bin
echo "$testScript" > $out/test-script
echo "$baseSetup" > $out/base-setup
ln -s ${testDriver}/bin/genode-test-driver $out/bin/
wrapProgram $out/bin/genode-test-driver \
--run "export testScript=\"\$(cat $out/test-script)\"" \
--run "export baseSetup=\"\$(cat $out/base-setup)\"" \
'';
test = runTests driver;
in test // {
inherit build driver test;
config = lib.runDhallCommand (name + ".dhall") env' ''
${apps.dhall.program} <<< "(${testConfig'}).config" > $out
'';
xml = lib.runDhallCommand (name + ".config") env' ''
${apps.render-init.program} <<< "(${testConfig'}).config" > $out
'';
image = lib.runDhallCommand (name + ".image.elf") env' ''
mkdir -p $out
pushd $out
. ${build}/script
'';
};
in {
callTest = path: args:
(import path ({
testEnv = {
inherit mkTest lib;
isLinux = true;
isNova = false;
};
pkgs = testPkgs;
inherit nixpkgs buildPackages;
} // args));
}

25
tests/driver-nova.nix

@ -40,10 +40,22 @@ let
mkTest = { name ? "unamed", testScript ? defaultScript, testConfig
, testInputs ? [ ], testEnv ? { }, qemuArgs ? [ ], ... }@t:
let
manifest = lib.mergeManifests (map addManifest (with testPkgs;
[ base-nova sotest-producer ]
++ map genodeSources.depot [ "init" "rtc_drv" ] ++ testInputs));
testConfig' = "${./test-wrapper.dhall} (${testConfig}) ${manifest}";
storeTarball = buildPackages.runCommand "store" { } ''
mkdir -p $out
tar cf "$out/store.tar" --absolute-names ${toString testInputs}
'';
storeManifest = lib.mergeManifests (map addManifest testInputs);
manifest = lib.mergeManifests (map addManifest
([ testPkgs.base-nova testPkgs.sotest-producer storeTarball ]
++ map testPkgs.genodeSources.depot [
"init"
"rtc_drv"
"vfs"
"cached_fs_rom"
]));
testConfig' = "${
./test-wrapper.dhall
} (${testConfig}) $(stat --format '%s' ${storeTarball}/store.tar) ${storeManifest} ${manifest}";
testEnv' = {
DHALL_GENODE = "${testPkgs.dhallGenode}/source.dhall";
DHALL_GENODE_TEST = "${./test.dhall}";
@ -143,6 +155,11 @@ let
compile = lib.compileBoot name testConfig';
iso = apps.nova-iso.function testEnv' "${testConfig'}";
store = storeTarball;
xml = buildPackages.runCommand (name + ".config") testEnv'
''${apps.render-init.program} <<< "(${testConfig'}).config" > $out'';
};
in {

2
tests/posix.nix

@ -6,7 +6,7 @@ with pkgs;
testEnv.mkTest rec {
name = "posix";
testConfig = ./posix.dhall;
testInputs = map pkgs.genodeSources.depot [ "vfs" "libc" "posix" ]
testInputs = map pkgs.genodeSources.depot [ "libc" "posix" ]
++ (with legacyPackages; [ coreutils hello ]);
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ];
}

99
tests/test-wrapper.dhall

@ -5,6 +5,8 @@ let Genode = Test.Genode
let Prelude = Genode.Prelude
let XML = Prelude.XML
let Init = Genode.Init
let Child = Init.Child
@ -13,9 +15,32 @@ let TextMapType = Prelude.Map.Type Text
let Children = TextMapType Child.Type
let Manifest/Type = TextMapType (TextMapType Text)
let Manifest/toRoutes =
λ(manifest : Manifest/Type)
→ Prelude.List.map
(Prelude.Map.Entry Text Text)
Init.ServiceRoute.Type
( λ(entry : Prelude.Map.Entry Text Text)
→ { service =
{ name = "ROM"
, label = Init.LabelSelector.Type.Last entry.mapKey
}
, route =
Init.Route.Type.Child
{ name = "store_rom", label = Some entry.mapValue }
}
)
( Prelude.List.concat
(Prelude.Map.Entry Text Text)
(Prelude.Map.values Text (Prelude.Map.Type Text Text) manifest)
)
let wrapHarness
: Children → Child.Type
: Children → Manifest/Type → Child.Type
= λ(children : Children)
→ λ(manifest : Manifest/Type)
→ Child.nested
children
Child.Attributes::{
@ -23,21 +48,24 @@ let wrapHarness
, exitPropagate = True
, resources = Init.Resources::{ ram = Genode.units.MiB 4 }
, routes =
[ Init.ServiceRoute.parentLabel
"LOG"
(Some "SOTEST")
(Some "unlabeled")
, Init.ServiceRoute.parent "IO_MEM"
, Init.ServiceRoute.parent "IO_PORT"
, Init.ServiceRoute.parent "IRQ"
, Init.ServiceRoute.parent "VM"
, Init.ServiceRoute.child "Timer" "timer"
, Init.ServiceRoute.child "Rtc" "rtc"
]
[ Init.ServiceRoute.parentLabel
"LOG"
(Some "SOTEST")
(Some "unlabeled")
, Init.ServiceRoute.parent "IO_MEM"
, Init.ServiceRoute.parent "IO_PORT"
, Init.ServiceRoute.parent "IRQ"
, Init.ServiceRoute.parent "VM"
, Init.ServiceRoute.child "Timer" "timer"
, Init.ServiceRoute.child "Rtc" "rtc"
]
# Manifest/toRoutes manifest
}
in λ(test : Test.Type)
→ λ(inputsManifest : TextMapType (TextMapType Text))
→ λ(storeSize : Natural)
→ λ(storeManifest : Manifest/Type)
→ λ(bootManifest : Manifest/Type)
→ Genode.Boot::{
, config = Init::{
, children =
@ -58,7 +86,48 @@ in λ(test : Test.Type)
, routes = [ Init.ServiceRoute.parent "IO_PORT" ]
}
}
, { mapKey = "harness", mapValue = wrapHarness test.children }
, { mapKey = "store_fs"
, mapValue =
Child.flat
Child.Attributes::{
, binary = "vfs"
, config = Init.Config::{
, content =
[ XML.element
{ name = "vfs"
, attributes = XML.emptyAttributes
, content =
[ XML.leaf
{ name = "tar"
, attributes = toMap { name = "store.tar" }
}
]
}
, XML.leaf
{ name = "default-policy"
, attributes = toMap { root = "/", writeable = "no" }
}
]
}
, provides = [ "File_system" ]
}
}
, { mapKey = "store_rom"
, mapValue =
Child.flat
Child.Attributes::{
, binary = "cached_fs_rom"
, provides = [ "ROM" ]
, resources = Init.Resources::{
, ram = storeSize + Genode.units.MiB 1
}
, routes =
[ Init.ServiceRoute.child "File_system" "store_fs" ]
}
}
, { mapKey = "harness"
, mapValue = wrapHarness test.children storeManifest
}
]
}
, rom =
@ -69,7 +138,7 @@ in λ(test : Test.Type)
( Prelude.Map.values
Text
(Prelude.Map.Type Text Text)
inputsManifest
bootManifest
)
)
}

Loading…
Cancel
Save