diff --git a/tests/driver-hw-config.dhall b/tests/driver-hw-config.dhall index 011385c..d2b8bbd 100644 --- a/tests/driver-hw-config.dhall +++ b/tests/driver-hw-config.dhall @@ -2,71 +2,37 @@ let Genode = env:DHALL_GENODE -let Prelude = Genode.Prelude - in λ(boot : Genode.Boot.Type) - → let child = - { mapKey = "test", mapValue = Genode.Init.toStart boot.config } - - in { config = - Genode.Init::{ - , defaultRoutes = - Genode.Init.default.defaultRoutes - # [ Genode.ServiceRoute.parent "IO_MEM" - , Genode.ServiceRoute.parent "IO_PORT" - , Genode.ServiceRoute.parent "IRQ" - , Genode.ServiceRoute.child "Timer" "timer" - ] - , children = - [ { mapKey = "timer" - , mapValue = - Genode.Init.Start::{ - , binary = "hw_timer_drv" - , resources = { caps = 96, ram = Genode.units.MiB 1 } - , provides = [ "Timer" ] - } + → { config = + Genode.Init::{ + , defaultRoutes = + Genode.Init.default.defaultRoutes + # [ Genode.ServiceRoute.parent "IO_MEM" + , Genode.ServiceRoute.parent "IO_PORT" + , Genode.ServiceRoute.parent "IRQ" + , Genode.ServiceRoute.child "Timer" "timer" + ] + , children = + [ { mapKey = "timer" + , mapValue = + Genode.Init.Start::{ + , binary = "hw_timer_drv" + , resources = { caps = 96, ram = Genode.units.MiB 1 } + , provides = [ "Timer" ] } - , { mapKey = "harness" - , mapValue = - Genode.Init.Start::{ - , binary = "sotest-harness" - , exitPropagate = True - , resources = - { caps = child.mapValue.resources.caps + 128 - , ram = - child.mapValue.resources.ram - + Genode.units.MiB 1 - } - , config = - Some - ( Prelude.XML.element - { name = "config" - , attributes = Prelude.XML.emptyAttributes - , content = - [ Genode.Init.Start.toXML - child.mapKey - child.mapValue - ] - } - ) - , routes = - [ Genode.ServiceRoute.parentLabel - "LOG" - (Some "SOTEST") - (Some "unlabeled") - ] - } - } - ] - } - , rom = - let manifest = env:MANIFEST - - in Genode.Boot.toRomPaths - [ manifest.base-hw-pc.lib.ld - , manifest.base-hw-pc.bin.hw_timer_drv - , manifest.os.bin.init - , manifest.sotest-producer.bin.sotest-harness - ] - # boot.rom + } + , { mapKey = "harness" + , mapValue = Genode.Init.toStart boot.config + } + ] } + , rom = + let manifest = env:MANIFEST + + in Genode.Boot.toRomPaths + [ manifest.base-hw-pc.lib.ld + , manifest.base-hw-pc.bin.hw_timer_drv + , manifest.os.bin.init + ] + # boot.rom + } diff --git a/tests/driver-hw.nix b/tests/driver-hw.nix index 588fd78..dc66f68 100644 --- a/tests/driver-hw.nix +++ b/tests/driver-hw.nix @@ -40,6 +40,7 @@ let , env ? { }, ... # TODO: remove ... }@t: let + testConfig' = "${./driver-hw-config.dhall} (${./sotest-wrapper.dhall} ${testConfig})"; manifest = lib.mergeManifests (with testPkgs; [ base-hw-pc genode.os sotest-producer ] ++ testInputs); @@ -49,8 +50,7 @@ let MANIFEST = manifest; } // env; - image = apps.hw-image.function env' - "${./driver-hw-config.dhall} ${testConfig}"; + image = apps.hw-image.function env' testConfig'; baseSetup = '' ## @@ -91,9 +91,10 @@ let global env global spawn_id + set TEST_MIB [expr ($env(TEST_RAM) / 1048576) + 12] spawn ${hostPkgs.qemu_test}/bin/qemu-system-x86_64 \ -machine q35 -serial mon:stdio -nographic \ - -m size=[expr ($env(TEST_RAM) / 1048576) + 16] \ + -m size=$TEST_MIB \ -kernel "${testPkgs.bender}" \ -initrd "${image}" wait_for_output $wait_for_re $timeout_value $spawn_id @@ -107,7 +108,7 @@ let driver = with hostPkgs; buildPackages.runCommand "genode-test-driver-${name}" { buildInputs = [ makeWrapper expect ]; - inherit baseSetup testConfig testScript; + inherit baseSetup testScript; preferLocalBuild = true; testName = name; DHALL_GENODE = "${testPkgs.dhallGenode}/package.dhall"; @@ -116,7 +117,7 @@ let mkdir -p $out/bin echo "$testScript" > $out/test-script echo "$baseSetup" > $out/base-setup - eval $(${apps.dhall-to-bash.program} --declare "TEST_RAM" <<< "${./boot-ram.dhall} ${testConfig}") + eval $(${apps.dhall-to-bash.program} --declare "TEST_RAM" <<< "${./boot-ram.dhall} (${testConfig'})") ln -s ${testDriver}/bin/genode-test-driver $out/bin/ wrapProgram $out/bin/genode-test-driver \ --set testScript "$testScript" \ @@ -135,17 +136,14 @@ let config = hostPkgs.runCommand (name + ".dhall") env' '' export XDG_CACHE_HOME=''${TMPDIR:-/tmp} - ${apps.dhall.program} <<< \ - "(${./driver-hw-config.dhall} ${testConfig})" > $out + ${apps.dhall.program} <<< "${testConfig'}" > $out ''; - iso = apps.hw-iso.function env' - "(${./driver-hw-config.dhall} ${testConfig})"; + iso = apps.hw-iso.function env' testConfig'; xml = hostPkgs.runCommand (name + ".config") env' '' export XDG_CACHE_HOME=''${TMPDIR:-/tmp} - ${apps.render-init.program} \ - "(${./driver-hw-config.dhall} ${testConfig}).config" > $out''; + ${apps.render-init.program} "(${testConfig'}).config" > $out''; sotest = hostPkgs.runCommand "hw-${name}-sotest" env' '' cp "${testPkgs.bender}" bender diff --git a/tests/driver-linux-config.dhall b/tests/driver-linux-config.dhall index 398b0ce..6ae4675 100644 --- a/tests/driver-linux-config.dhall +++ b/tests/driver-linux-config.dhall @@ -1,70 +1,36 @@ -- SPDX-License-Identifier: CC0-1.0 let Genode = env:DHALL_GENODE -let Prelude = Genode.Prelude - in λ(boot : Genode.Boot.Type) - → let child = - { mapKey = "test", mapValue = Genode.Init.toStart boot.config } - - in { config = - Genode.Init::{ - , verbose = True - , defaultRoutes = - Genode.Init.default.defaultRoutes - # [ Genode.ServiceRoute.child "Timer" "timer" ] - , children = - [ { mapKey = "timer" - , mapValue = - Genode.Init.Start::{ - , binary = "linux_timer_drv" - , resources = { caps = 96, ram = Genode.units.MiB 1 } - , provides = [ "Timer" ] - } + → { config = + Genode.Init::{ + , verbose = True + , defaultRoutes = + Genode.Init.default.defaultRoutes + # [ Genode.ServiceRoute.child "Timer" "timer" ] + , children = + [ { mapKey = "timer" + , mapValue = + Genode.Init.Start::{ + , binary = "linux_timer_drv" + , resources = { caps = 96, ram = Genode.units.MiB 1 } + , provides = [ "Timer" ] } - , { mapKey = "harness" - , mapValue = - Genode.Init.Start::{ - , binary = "sotest-harness" - , exitPropagate = True - , resources = - { caps = child.mapValue.resources.caps + 128 - , ram = - child.mapValue.resources.ram - + Genode.units.MiB 1 - } - , config = - Some - ( Prelude.XML.element - { name = "config" - , attributes = Prelude.XML.emptyAttributes - , content = - [ Genode.Init.Start.toXML - child.mapKey - child.mapValue - ] - } - ) - , routes = - [ Genode.ServiceRoute.parentLabel - "LOG" - (Some "SOTEST") - (Some "unlabeled") - ] - } - } - ] - } - , rom = - let manifest = env:MANIFEST - - in Genode.Boot.toRomPaths - [ manifest.base-linux.bin.core-linux - , manifest.base-linux.bin.ld - , manifest.base-linux.bin.linux_timer_drv - , manifest.os.bin.init - , manifest.sotest-producer.bin.sotest-harness - ] - # boot.rom - : Genode.Prelude.Map.Type Text Genode.Boot.Rom + } + , { mapKey = "harness" + , mapValue = Genode.Init.toStart boot.config + } + ] } + , rom = + let manifest = env:MANIFEST + + in Genode.Boot.toRomPaths + [ manifest.base-linux.bin.core-linux + , manifest.base-linux.bin.ld + , manifest.base-linux.bin.linux_timer_drv + , manifest.os.bin.init + ] + # boot.rom + : Genode.Prelude.Map.Type Text Genode.Boot.Rom + } diff --git a/tests/driver-linux.nix b/tests/driver-linux.nix index 7ae09b8..fc567c7 100644 --- a/tests/driver-linux.nix +++ b/tests/driver-linux.nix @@ -71,7 +71,7 @@ let set env(XDG_CACHE_HOME) /tmp exec ${apps.linux-image.program} \ - ${./driver-linux-config.dhall} ${testConfig} + ${./driver-linux-config.dhall} (${./sotest-wrapper.dhall} ${testConfig}) spawn ./core-linux wait_for_output $wait_for_re $timeout_value $spawn_id diff --git a/tests/driver-nova-config.dhall b/tests/driver-nova-config.dhall index b54081a..429636a 100644 --- a/tests/driver-nova-config.dhall +++ b/tests/driver-nova-config.dhall @@ -2,71 +2,37 @@ let Genode = env:DHALL_GENODE -let Prelude = Genode.Prelude - in λ(boot : Genode.Boot.Type) - → let child = - { mapKey = "test", mapValue = Genode.Init.toStart boot.config } - - in { config = - Genode.Init::{ - , defaultRoutes = - Genode.Init.default.defaultRoutes - # [ Genode.ServiceRoute.parent "IO_MEM" - , Genode.ServiceRoute.parent "IO_PORT" - , Genode.ServiceRoute.parent "IRQ" - , Genode.ServiceRoute.child "Timer" "timer" - ] - , children = - [ { mapKey = "timer" - , mapValue = - Genode.Init.Start::{ - , binary = "nova_timer_drv" - , resources = { caps = 96, ram = Genode.units.MiB 1 } - , provides = [ "Timer" ] - } + → { config = + Genode.Init::{ + , defaultRoutes = + Genode.Init.default.defaultRoutes + # [ Genode.ServiceRoute.parent "IO_MEM" + , Genode.ServiceRoute.parent "IO_PORT" + , Genode.ServiceRoute.parent "IRQ" + , Genode.ServiceRoute.child "Timer" "timer" + ] + , children = + [ { mapKey = "timer" + , mapValue = + Genode.Init.Start::{ + , binary = "nova_timer_drv" + , resources = { caps = 96, ram = Genode.units.MiB 1 } + , provides = [ "Timer" ] } - , { mapKey = "harness" - , mapValue = - Genode.Init.Start::{ - , binary = "sotest-harness" - , exitPropagate = True - , resources = - { caps = child.mapValue.resources.caps + 128 - , ram = - child.mapValue.resources.ram - + Genode.units.MiB 1 - } - , config = - Some - ( Prelude.XML.element - { name = "config" - , attributes = Prelude.XML.emptyAttributes - , content = - [ Genode.Init.Start.toXML - child.mapKey - child.mapValue - ] - } - ) - , routes = - [ Genode.ServiceRoute.parentLabel - "LOG" - (Some "SOTEST") - (Some "unlabeled") - ] - } - } - ] - } - , rom = - let manifest = env:MANIFEST - - in Genode.Boot.toRomPaths - [ manifest.base-nova.lib.ld - , manifest.base-nova.bin.nova_timer_drv - , manifest.os.bin.init - , manifest.sotest-producer.bin.sotest-harness - ] - # boot.rom + } + , { mapKey = "harness" + , mapValue = Genode.Init.toStart boot.config + } + ] } + , rom = + let manifest = env:MANIFEST + + in Genode.Boot.toRomPaths + [ manifest.base-nova.lib.ld + , manifest.base-nova.bin.nova_timer_drv + , manifest.os.bin.init + ] + # boot.rom + } diff --git a/tests/driver-nova.nix b/tests/driver-nova.nix index d31118d..01c1836 100644 --- a/tests/driver-nova.nix +++ b/tests/driver-nova.nix @@ -40,6 +40,7 @@ let , env ? { }, ... # TODO: remove ... }@t: let + testConfig' = "${./driver-nova-config.dhall} (${./sotest-wrapper.dhall} ${testConfig})"; manifest = lib.mergeManifests (with testPkgs; [ base-nova genode.os sotest-producer ] ++ testInputs); @@ -49,8 +50,7 @@ let MANIFEST = manifest; } // env; - image = apps.nova-image.function env' - "${./driver-nova-config.dhall} ${testConfig}"; + image = apps.nova-image.function env' testConfig'; baseSetup = '' ## @@ -91,9 +91,10 @@ let global env global spawn_id + set TEST_MIB [expr ($env(TEST_RAM) / 1048576) + 24] spawn ${hostPkgs.qemu_test}/bin/qemu-system-x86_64 \ -machine q35 -serial mon:stdio -nographic \ - -m size=[expr ($env(TEST_RAM) / 1048576) + 16] \ + -m size=$TEST_MIB \ -kernel "${testPkgs.bender}" \ -initrd "${testPkgs.NOVA}/hypervisor-x86_64 arg=iommu novpid serial,${image}" wait_for_output $wait_for_re $timeout_value $spawn_id @@ -107,7 +108,7 @@ let driver = with hostPkgs; buildPackages.runCommand "genode-test-driver-${name}" { buildInputs = [ makeWrapper expect ]; - inherit baseSetup testConfig testScript; + inherit baseSetup testScript; preferLocalBuild = true; testName = name; DHALL_GENODE = "${testPkgs.dhallGenode}/package.dhall"; @@ -116,7 +117,7 @@ let mkdir -p $out/bin echo "$testScript" > $out/test-script echo "$baseSetup" > $out/base-setup - eval $(${apps.dhall-to-bash.program} --declare "TEST_RAM" <<< "${./boot-ram.dhall} ${testConfig}") + eval $(${apps.dhall-to-bash.program} --declare "TEST_RAM" <<< "${./boot-ram.dhall} (${testConfig'})") ln -s ${testDriver}/bin/genode-test-driver $out/bin/ wrapProgram $out/bin/genode-test-driver \ --set testScript "$testScript" \ @@ -135,17 +136,14 @@ let config = hostPkgs.runCommand (name + ".dhall") env' '' export XDG_CACHE_HOME=''${TMPDIR:-/tmp} - ${apps.dhall.program} <<< \ - "(${./driver-nova-config.dhall} ${testConfig})" > $out + ${apps.dhall.program} <<< "${testConfig'}" > $out ''; - iso = apps.nova-iso.function env' - "(${./driver-nova-config.dhall} ${testConfig})"; + iso = apps.nova-iso.function env' "${testConfig'}"; xml = hostPkgs.runCommand (name + ".config") env' '' export XDG_CACHE_HOME=''${TMPDIR:-/tmp} - ${apps.render-init.program} \ - "(${./driver-nova-config.dhall} ${testConfig}).config" > $out''; + ${apps.render-init.program} "(${testConfig'}).config" > $out''; sotest = hostPkgs.runCommand "nova-${name}-sotest" env' '' cp "${testPkgs.bender}" bender diff --git a/tests/sotest-wrapper.dhall b/tests/sotest-wrapper.dhall new file mode 100644 index 0000000..6edab4b --- /dev/null +++ b/tests/sotest-wrapper.dhall @@ -0,0 +1,53 @@ +-- SPDX-License-Identifier: CC0-1.0 +let Genode = env:DHALL_GENODE + +let Prelude = Genode.Prelude + +in λ(boot : Genode.Boot.Type) + → let child = + { mapKey = "test", mapValue = Genode.Init.toStart boot.config } + + in { config = + Genode.Init::{ + , verbose = True + , children = + toMap + { harness = + Genode.Init.Start::{ + , binary = "sotest-harness" + , exitPropagate = True + , resources = + { caps = child.mapValue.resources.caps + 128 + , ram = + child.mapValue.resources.ram + + Genode.units.MiB 1 + } + , config = + Some + ( Prelude.XML.element + { name = "config" + , attributes = Prelude.XML.emptyAttributes + , content = + [ Genode.Init.Start.toXML + child.mapKey + child.mapValue + ] + } + ) + , routes = + [ Genode.ServiceRoute.parentLabel + "LOG" + (Some "SOTEST") + (Some "unlabeled") + ] + } + } + } + , rom = + let manifest = env:MANIFEST + + in Genode.Boot.toRomPaths + [ manifest.sotest-producer.bin.sotest-harness ] + # boot.rom + : Genode.Prelude.Map.Type Text Genode.Boot.Rom + }