Browse Source

Apply manifest merging in tests

Merged manifests are easier to work with as the number of inputs increase.
20.02
Emery Hemingway 2 years ago
parent
commit
fffd53664b
  1. 13
      lib/default.nix
  2. 2
      packages/default.nix
  3. 10
      tests/default.nix
  4. 12
      tests/driver-linux-config.dhall
  5. 21
      tests/driver-linux.nix
  6. 14
      tests/driver-nova-config.dhall
  7. 33
      tests/driver-nova.nix
  8. 15
      tests/fs_report.dhall
  9. 4
      tests/log.dhall
  10. 10
      tests/pci.dhall
  11. 5
      tests/rtc.dhall
  12. 4
      tests/signal.dhall
  13. 7
      tests/solo5/blk.dhall
  14. 5
      tests/solo5/boot-wrapper.dhall
  15. 7
      tests/solo5/default.nix
  16. 12
      tests/solo5/net.dhall
  17. 14
      tests/solo5/net_2if.dhall
  18. 8
      tests/solo5/time.dhall

13
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) + "}";
};
}

2
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;

10
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)

12
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

21
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}"
'';
};

14
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
}

33
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

15
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
]
}

4
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 ]
}

10
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
]
}

5
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 ]
}

4
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 ]
}

7
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 ]
}

5
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
}

7
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 = [
{

12
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
]
}

14
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
]
}

8
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 ]
}

Loading…
Cancel
Save