From fffd53664b52d9ed5ded031cc3011955bf169243 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Sat, 25 Jan 2020 00:17:33 +0100 Subject: [PATCH] Apply manifest merging in tests Merged manifests are easier to work with as the number of inputs increase. --- lib/default.nix | 13 +++++++++++++ packages/default.nix | 2 +- tests/default.nix | 10 ++++++---- tests/driver-linux-config.dhall | 12 +++++------- tests/driver-linux.nix | 21 ++++++++++----------- tests/driver-nova-config.dhall | 14 +++++--------- tests/driver-nova.nix | 33 ++++++++++++++++----------------- tests/fs_report.dhall | 15 ++++++++------- tests/log.dhall | 4 ++-- tests/pci.dhall | 10 +++++----- tests/rtc.dhall | 5 +++-- tests/signal.dhall | 4 ++-- tests/solo5/blk.dhall | 7 +++---- tests/solo5/boot-wrapper.dhall | 5 ++--- tests/solo5/default.nix | 7 ++----- tests/solo5/net.dhall | 12 +++++------- tests/solo5/net_2if.dhall | 14 ++++++-------- tests/solo5/time.dhall | 8 +++----- 18 files changed, 97 insertions(+), 99 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index b0a5104..7a5428a 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -45,4 +45,17 @@ in { xmllint --noout $out ''; + mergeManifests = inputs: + nixpkgs.legacyPackages.${localSystem}.writeTextFile { + name = "manifest.dhall"; + text = with builtins; + let + f = head: input: + if hasAttr "manifest" input then + "${head},${input.pname}=${input.manifest}" + else + abort "${input.pname} does not have a manifest"; + in (foldl' f "{" inputs) + "}"; + }; + } diff --git a/packages/default.nix b/packages/default.nix index d62c492..1a3f0c1 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -36,7 +36,7 @@ in rec { nic_bus = callPackage ./nic_bus { inherit (genode) base os; }; solo5 = let drv = callPackage ./solo5 { inherit (genode) base os; }; - in addManifest drv // { tests = addManifest drv.tests; }; + in addManifest drv // { tests = addManifest drv.tests // { pname = "solo5-tests"; }; }; sotest-producer = addManifest (callPackage ./sotest-producer { stdenv = genode.stdenvGcc; diff --git a/tests/default.nix b/tests/default.nix index c8507d4..0a57576 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -20,8 +20,11 @@ let inherit apps testPkgs hostPkgs lib depot; }).callTest; - nova = (call: ((tests call) // { pci = call ./pci.nix { }; rtc = call ./rtc.nix { }; })) - (import ./driver-nova.nix { + nova = (call: + ((tests call) // { + pci = call ./pci.nix { }; + rtc = call ./rtc.nix { }; + })) (import ./driver-nova.nix { inherit apps system testPkgs hostPkgs lib depot; }).callTest; @@ -37,5 +40,4 @@ let }) (testsToList nova); in with builtins; -listToAttrs -((concatLists (map (testsToList) [ linux nova ])) ++ nova-sotest) +listToAttrs ((concatLists (map (testsToList) [ linux nova ])) ++ nova-sotest) diff --git a/tests/driver-linux-config.dhall b/tests/driver-linux-config.dhall index c70433c..8694fc7 100644 --- a/tests/driver-linux-config.dhall +++ b/tests/driver-linux-config.dhall @@ -27,17 +27,15 @@ in λ(args : Args) ] } , rom = - let baseLinux = env:BASE_LINUX_MANIFEST - - let os = env:OS_MANIFEST + let manifest = env:MANIFEST in Genode.Boot.toRomPaths [ { mapKey = "ld.lib.so" - , mapValue = baseLinux.bin.ld-linux.mapValue + , mapValue = manifest.base-linux.bin.ld-linux.mapValue } - , baseLinux.bin.linux_timer_drv - , os.bin.init - , baseLinux.bin.core-linux + , manifest.base-linux.bin.linux_timer_drv + , manifest.os.bin.init + , manifest.base-linux.bin.core-linux ] # args.rom : Genode.Prelude.Map.Type Text Genode.Boot.Rom diff --git a/tests/driver-linux.nix b/tests/driver-linux.nix index a1c3beb..8623dfd 100644 --- a/tests/driver-linux.nix +++ b/tests/driver-linux.nix @@ -34,15 +34,15 @@ let ''; }; - mkTest = { name ? "unamed", testScript, testConfig, env ? { }, ... }: + mkTest = { name ? "unamed", testScript, testConfig, testInputs ? [ ] + , env ? { }, ... }: with testPkgs; let env' = { DHALL_PRELUDE = "${testPkgs.dhallPrelude}/package.dhall"; DHALL_GENODE = "${testPkgs.dhallGenode}/package.dhall"; - BASE_MANIFEST = testPkgs.genode.base.manifest; - BASE_LINUX_MANIFEST = testPkgs.genode.base-linux.manifest; - OS_MANIFEST = testPkgs.genode.os.manifest; + MANIFEST = lib.mergeManifests (with testPkgs; + [ genode.base genode.base-linux genode.os ] ++ testInputs); } // env; toExports = env: @@ -99,19 +99,18 @@ let in test // { inherit driver test; config = hostPkgs.runCommand (name + ".dhall") env' '' - ${apps.dhall.program} <<< "(${ - ./driver-linux-config.dhall - } ${testConfig})" > $out + ${apps.dhall.program} <<< \ + "(${./driver-linux-config.dhall} ${testConfig})" > $out ''; xml = hostPkgs.runCommand (name + ".config") env' '' - ${apps.render-init.program} "(${ - ./driver-linux-config.dhall - } ${testConfig}).config" > $out + ${apps.render-init.program} \ + "(${./driver-linux-config.dhall} ${testConfig}).config" > $out ''; image = hostPkgs.runCommand (name + ".config") env' '' mkdir -p $out pushd $out - ${apps.linux-image.program} "${./driver-linux-config.dhall} ${testConfig}" + ${apps.linux-image.program} \ + "${./driver-linux-config.dhall} ${testConfig}" ''; }; diff --git a/tests/driver-nova-config.dhall b/tests/driver-nova-config.dhall index 6d68225..21878c9 100644 --- a/tests/driver-nova-config.dhall +++ b/tests/driver-nova-config.dhall @@ -61,19 +61,15 @@ in λ(args : Args) ] } , rom = - let baseNova = env:BASE_NOVA_MANIFEST - - let os = env:OS_MANIFEST - - let sotest = env:SOTEST_PRODUCER_MANIFEST + let manifest = env:MANIFEST in Genode.Boot.toRomPaths [ { mapKey = "ld.lib.so" - , mapValue = baseNova.lib.ld-nova.mapValue + , mapValue = manifest.base-nova.lib.ld-nova.mapValue } - , baseNova.bin.nova_timer_drv - , os.bin.init - , sotest.bin.sotest-harness + , manifest.base-nova.bin.nova_timer_drv + , manifest.os.bin.init + , manifest.sotest-producer.bin.sotest-harness ] # args.rom } diff --git a/tests/driver-nova.nix b/tests/driver-nova.nix index e6a2fc6..8d86cbc 100644 --- a/tests/driver-nova.nix +++ b/tests/driver-nova.nix @@ -34,17 +34,17 @@ let ''; }; - mkTest = { name ? "unamed", testScript, testConfig, env ? { }, qemuMem ? 32 - , ... # TODO: remove ... + mkTest = { name ? "unamed", testScript, testConfig, testInputs ? [ ] + , env ? { }, qemuMem ? 32, ... # TODO: remove ... }@t: let + manifest = lib.mergeManifests (with testPkgs; + [ genode.base genode.base-nova genode.os sotest-producer ] + ++ testInputs); env' = { DHALL_PRELUDE = "${testPkgs.dhallPrelude}/package.dhall"; DHALL_GENODE = "${testPkgs.dhallGenode}/package.dhall"; - BASE_MANIFEST = testPkgs.genode.base.manifest; - BASE_NOVA_MANIFEST = testPkgs.genode.base-nova.manifest; - OS_MANIFEST = testPkgs.genode.os.manifest; - SOTEST_PRODUCER_MANIFEST = testPkgs.sotest-producer.manifest; + MANIFEST = manifest; } // env; iso = apps.nova-iso.function env' @@ -127,24 +127,23 @@ let test = passMeta (runTests driver); in test // { - inherit driver iso test; + inherit driver iso test manifest; config = hostPkgs.runCommand (name + ".dhall") env' '' - export XDG_CACHE_HOME=${TMPDIR:-/tmp} - ${apps.dhall.program} <<< "(${ - ./driver-nova-config.dhall - } ${testConfig})" > $out + export XDG_CACHE_HOME=''${TMPDIR:-/tmp} + ${apps.dhall.program} <<< \ + "(${./driver-nova-config.dhall} ${testConfig})" > $out ''; xml = hostPkgs.runCommand (name + ".config") env' '' - export XDG_CACHE_HOME=${TMPDIR:-/tmp} - ${apps.render-init.program} "(${ - ./driver-nova-config.dhall - } ${testConfig}).config" > $out''; + export XDG_CACHE_HOME=''${TMPDIR:-/tmp} + ${apps.render-init.program} \ + "(${./driver-nova-config.dhall} ${testConfig}).config" > $out''; sotest = hostPkgs.runCommand "nova-${name}-sotest" env' '' - export XDG_CACHE_HOME=${TMPDIR:-/tmp} - ${apps.nova-image.program} image.elf "${./driver-nova-config.dhall} ${testConfig}" + export XDG_CACHE_HOME=''${TMPDIR:-/tmp} + ${apps.nova-image.program} \ + image.elf "${./driver-nova-config.dhall} ${testConfig}" cp "${testPkgs.bender}" bender cp "${testPkgs.NOVA}/hypervisor-x86_64" hypervisor mkdir -p $out/nix-support diff --git a/tests/fs_report.dhall b/tests/fs_report.dhall index 10eb6fd..5a062a4 100644 --- a/tests/fs_report.dhall +++ b/tests/fs_report.dhall @@ -81,12 +81,13 @@ in { config = } } , rom = - let os = env:OS_MANIFEST + let manifest = env:MANIFEST - in [ os.bin.fs_report - , os.bin.fs_rom - , os.bin.ram_fs - , os.bin.test-fs_report - , os.lib.vfs - ] + in Genode.Boot.toRomPaths + [ manifest.os.bin.fs_report + , manifest.os.bin.fs_rom + , manifest.os.bin.ram_fs + , manifest.os.bin.test-fs_report + , manifest.os.lib.vfs + ] } diff --git a/tests/log.dhall b/tests/log.dhall index d9797ed..d5a28b6 100644 --- a/tests/log.dhall +++ b/tests/log.dhall @@ -17,7 +17,7 @@ in { config = } } , rom = - let base = env:BASE_MANIFEST + let manifest = env:MANIFEST - in Genode.Boot.toRomPaths [ base.bin.test-log ] + in Genode.Boot.toRomPaths [ manifest.base.bin.test-log ] } diff --git a/tests/pci.dhall b/tests/pci.dhall index c41f19b..4a17552 100644 --- a/tests/pci.dhall +++ b/tests/pci.dhall @@ -74,12 +74,12 @@ in { config = } } , rom = - let os = env:OS_MANIFEST + let manifest = env:MANIFEST in Genode.Boot.toRomPaths - [ os.bin.acpi_drv - , os.bin.platform_drv - , os.bin.report_rom - , os.bin.test-pci + [ manifest.os.bin.acpi_drv + , manifest.os.bin.platform_drv + , manifest.os.bin.report_rom + , manifest.os.bin.test-pci ] } diff --git a/tests/rtc.dhall b/tests/rtc.dhall index d1a5166..1473363 100644 --- a/tests/rtc.dhall +++ b/tests/rtc.dhall @@ -26,7 +26,8 @@ in { config = } } , rom = - let os = env:OS_MANIFEST + let manifest = env:MANIFEST - in Genode.Boot.toRomPaths [ os.bin.test-rtc, os.bin.rtc_drv ] + in Genode.Boot.toRomPaths + [ manifest.os.bin.test-rtc, manifest.os.bin.rtc_drv ] } diff --git a/tests/signal.dhall b/tests/signal.dhall index 3189d72..4761a38 100644 --- a/tests/signal.dhall +++ b/tests/signal.dhall @@ -17,7 +17,7 @@ in { config = } } , rom = - let os = env:OS_MANIFEST + let manifest = env:MANIFEST - in Genode.Boot.toRomPaths [ os.bin.test-signal ] + in Genode.Boot.toRomPaths [ manifest.os.bin.test-signal ] } diff --git a/tests/solo5/blk.dhall b/tests/solo5/blk.dhall index 66c5e58..c0dc6e1 100644 --- a/tests/solo5/blk.dhall +++ b/tests/solo5/blk.dhall @@ -2,9 +2,7 @@ let Genode = env:DHALL_GENODE -let os = env:OS_MANIFEST - -let tests = env:SOLO5_TEST_MANIFEST +let manifest = env:MANIFEST in { config = Genode.Init::{ @@ -36,5 +34,6 @@ in { config = } } , rom = - Genode.Boot.toRomPaths [ tests.bin.solo5-test_blk, os.bin.ram_block ] + Genode.Boot.toRomPaths + [ manifest.solo5-tests.bin.solo5-test_blk, manifest.os.bin.ram_block ] } diff --git a/tests/solo5/boot-wrapper.dhall b/tests/solo5/boot-wrapper.dhall index de2d463..a3f91b7 100644 --- a/tests/solo5/boot-wrapper.dhall +++ b/tests/solo5/boot-wrapper.dhall @@ -2,13 +2,12 @@ let Genode = env:DHALL_GENODE -let solo5 = env:SOLO5_MANIFEST - let RomMap = Genode.Prelude.Map.Type Text Genode.Boot.Rom let Args = { config : Genode.Init.Type, rom : RomMap } : Type in λ(boot : Args) → { config = boot.config - , rom = Genode.Boot.toRomPaths [ solo5.lib.solo5 ] # boot.rom + , rom = + Genode.Boot.toRomPaths [ (env:MANIFEST).solo5.lib.solo5 ] # boot.rom } diff --git a/tests/solo5/default.nix b/tests/solo5/default.nix index 0cc3245..67f5745 100644 --- a/tests/solo5/default.nix +++ b/tests/solo5/default.nix @@ -12,10 +12,7 @@ let testEnv.mkTest (attrs // { name = "solo5-" + name; inherit testScript; - env = { - SOLO5_MANIFEST = pkgs.solo5.manifest; - SOLO5_TEST_MANIFEST = pkgs.solo5.tests.manifest; - }; + testInputs = [ pkgs.solo5 pkgs.solo5.tests ]; testConfig = "(${./boot-wrapper.dhall} ${testConfig})"; }); @@ -27,7 +24,7 @@ let mkTests = testList: builtins.listToAttrs (map applyMkTest testList); toSimple = name: - "(${./simple.dhall} (env:SOLO5_TEST_MANIFEST).bin.solo5-test_${name})"; + "(${./simple.dhall} (env:MANIFEST).solo5-tests.bin.solo5-test_${name})"; tests = [ { diff --git a/tests/solo5/net.dhall b/tests/solo5/net.dhall index 7dd1777..ea98ddb 100644 --- a/tests/solo5/net.dhall +++ b/tests/solo5/net.dhall @@ -2,9 +2,7 @@ let Genode = env:DHALL_GENODE -let os = env:OS_MANIFEST - -let tests = env:SOLO5_TEST_MANIFEST +let manifest = env:MANIFEST in { config = Genode.Init::{ @@ -73,9 +71,9 @@ in { config = } , rom = Genode.Boot.toRomPaths - [ os.bin.nic_loopback - , os.bin.nic_bridge - , os.bin.ping - , tests.bin.solo5-test_net + [ manifest.os.bin.nic_loopback + , manifest.os.bin.nic_bridge + , manifest.os.bin.ping + , manifest.solo5-tests.bin.solo5-test_net ] } diff --git a/tests/solo5/net_2if.dhall b/tests/solo5/net_2if.dhall index 12bc82b..de09a92 100644 --- a/tests/solo5/net_2if.dhall +++ b/tests/solo5/net_2if.dhall @@ -2,9 +2,7 @@ let Genode = env:DHALL_GENODE -let os = env:OS_MANIFEST - -let tests = env:SOLO5_TEST_MANIFEST +let manifest = env:MANIFEST in { config = Genode.Init::{ @@ -79,10 +77,10 @@ in { config = } , rom = Genode.Boot.toRomPaths - [ tests.bin.solo5-test_net_2if - , os.bin.sequence - , os.bin.nic_bridge - , os.bin.nic_loopback - , os.bin.ping + [ manifest.solo5-tests.bin.solo5-test_net_2if + , manifest.os.bin.sequence + , manifest.os.bin.nic_bridge + , manifest.os.bin.nic_loopback + , manifest.os.bin.ping ] } diff --git a/tests/solo5/time.dhall b/tests/solo5/time.dhall index ef1eca8..6aaced3 100644 --- a/tests/solo5/time.dhall +++ b/tests/solo5/time.dhall @@ -2,11 +2,9 @@ let Genode = env:DHALL_GENODE -let os = env:OS_MANIFEST +let manifest = env:MANIFEST -let tests = env:SOLO5_TEST_MANIFEST - -let test = tests.bin.solo5-test_time +let test = manifest.solo5-tests.bin.solo5-test_time in { config = Genode.Init::{ @@ -30,5 +28,5 @@ in { config = } } } - , rom = Genode.Boot.toRomPaths [ test, os.bin.rtc_drv ] + , rom = Genode.Boot.toRomPaths [ test, manifest.os.bin.rtc_drv ] }