From b7f3cfaa89c4e9e745558f26ed1a287370822a0d Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Sun, 19 Apr 2020 10:59:53 +0530 Subject: [PATCH] Test of tftp_rom --- packages/default.nix | 4 +- packages/genodelabs/default.nix | 5 +- packages/genodelabs/ports.nix | 2 +- packages/genodelabs/targets.nix | 2 + packages/rom_benchmark/default.nix | 36 +++++++ tests/default.nix | 1 + tests/driver-nova.nix | 7 +- tests/solo5/default.nix | 2 +- tests/test-wrapper.dhall | 6 ++ tests/tftp_rom.dhall | 153 +++++++++++++++++++++++++++++ tests/tftp_rom.nix | 31 ++++++ 11 files changed, 242 insertions(+), 7 deletions(-) create mode 100644 packages/rom_benchmark/default.nix create mode 100644 tests/tftp_rom.dhall create mode 100644 tests/tftp_rom.nix diff --git a/packages/default.nix b/packages/default.nix index 697eec6..4e0a811 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -99,6 +99,8 @@ in depotPkgs // { NOVA = callPackage ./NOVA { }; + rom_benchmark = callPackage ./rom_benchmark { }; + solo5 = let drv = callPackage ./solo5 { }; in drv // { tests = drv.tests // { pname = "solo5-tests"; }; }; @@ -118,7 +120,7 @@ in depotPkgs // { owner = "ehmry"; repo = "genode-world"; rev = "tftp_rom"; - hash = "sha256-C+M7H1duQbT6twWpx44C6MBh4JPyCdg5h3nqpMZAcHA="; + hash = "sha256-xYjLbGcz49I/AxSaNT3kB4BmaYGxhwxtbw+PZxgAbnQ="; }; in "echo 'REPOSITORIES += ${genodeWorld}' >> $BUILD_DIR/etc/build.conf"; portInputs = with genodeSources.ports; [ lwip ]; diff --git a/packages/genodelabs/default.nix b/packages/genodelabs/default.nix index d30902f..4f8a14d 100644 --- a/packages/genodelabs/default.nix +++ b/packages/genodelabs/default.nix @@ -251,10 +251,11 @@ in genodeSources // { inherit buildUpstream buildDepot ports specs toolchain genodeBase; make = target: - buildUpstream { + let attrs = buildOverrides.${target} or { }; + in buildUpstream ({ name = builtins.replaceStrings [ "/" ] [ "-" ] target; targets = [ target ]; - }; + } // attrs); depot = name: let attrs = buildOverrides.${name} or { }; diff --git a/packages/genodelabs/ports.nix b/packages/genodelabs/ports.nix index 2bb2722..5ea423c 100644 --- a/packages/genodelabs/ports.nix +++ b/packages/genodelabs/ports.nix @@ -2,7 +2,7 @@ { buildPackages }: with buildPackages; { dde_bsd.hash = "sha256-2ilZs6JkcQAvU/sQYnHunGtGRZDt7qLTpKZxQxSOf2I="; - dde_ipxe.hash = "sha256-uK110Cr01D6I2Fo0ZNP5U7rheseuH7LsghSPdFaGU3k="; + dde_ipxe.hash = "sha256-Rulyc1r5xPwsOnVQobcB6Z67XWM5CF/PwyRVng9MFO8="; dde_linux.hash = "sha256-3G5Mprv9ZBNhDJRuVF6Nrkp3KbFaN10IKFq0OdyAY9M="; dde_rump = { hash = "sha256-Wr5otGkWEa+5xImsFHQzwap5LckNEbyWA/7xbNcOreI="; diff --git a/packages/genodelabs/targets.nix b/packages/genodelabs/targets.nix index 078130b..ade6e8a 100644 --- a/packages/genodelabs/targets.nix +++ b/packages/genodelabs/targets.nix @@ -8,6 +8,8 @@ with ports; { portInputs = [ dde_linux ]; }; + ipxe_nic_drv.portInputs = [ dde_ipxe ]; + libc.portInputs = [ libc ]; lighttpd.portInputs = [ libc lighttpd openssl zlib ]; diff --git a/packages/rom_benchmark/default.nix b/packages/rom_benchmark/default.nix new file mode 100644 index 0000000..91dda0e --- /dev/null +++ b/packages/rom_benchmark/default.nix @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: CC0-1.0 + +{ stdenv, fetchgit, buildPackages }: + +stdenv.mkDerivation rec { + pname = "rom_benchmark"; + version = "0.1"; + + nativeBuildInputs = with buildPackages; [ tup ]; + + src = fetchgit { + url = "https://git.sr.ht/~ehmry/rom_benchmark"; + rev = "v" + version; + sha256 = "0j0ir4zv0bxf0d2k0giykcm3wwqr4wdv3ix42751sd9v1wwgbbjg"; + }; + + configurePhase = '' + # Scan repository and generate script + tup init + tup generate buildPhase.sh + ''; + + buildPhase = '' + pushd . + source buildPhase.sh + popd + ''; + + installPhase = "install -Dm755 {.,$out}/rom_benchmark"; + + meta = with stdenv.lib; { + license = licenses.gpl3; + maintainers = [ maintainers.ehmry ]; + }; + +} diff --git a/tests/default.nix b/tests/default.nix index 644c7ac..5c01b79 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -34,6 +34,7 @@ let noux = call ./noux.nix { }; pci = call ./pci.nix { }; rtc = call ./rtc.nix { }; + tftp_rom = call ./tftp_rom.nix { }; })) (import ./driver-nova.nix { inherit apps addManifest buildPackages depot lib nixpkgs testPkgs; }).callTest; diff --git a/tests/driver-nova.nix b/tests/driver-nova.nix index ebf94d8..dab833c 100644 --- a/tests/driver-nova.nix +++ b/tests/driver-nova.nix @@ -38,7 +38,8 @@ let ''run_genode_until {[init] child "harness" exited with exit value 0} 60''; mkTest = { name ? "unamed", testScript ? defaultScript, testConfig - , testInputs ? [ ], testEnv ? { }, qemuArgs ? [ ], sotest ? false, ... }@t: + , testInputs ? [ ], testEnv ? { }, qemuArgs ? [ ], sotest ? false + , extraSotest ? [ ], ... }@t: let manifest = lib.mergeManifests (map addManifest (with testPkgs; [ base-nova (genodeSources.make "init") sotest-producer ] @@ -123,6 +124,7 @@ let --set testScript "$testScript" \ --set baseSetup "$baseSetup" \ --set TEST_RAM $RAM \ + --set-default out /tmp \ ''; passMeta = drv: @@ -148,9 +150,10 @@ let cp "${testPkgs.bender}" bender cp "${testPkgs.NOVA}/hypervisor-x86_64" hypervisor cp ${image} image.elf + find ${toString extraSotest} -type f -exec cp {} ./ \; mkdir -p $out/nix-support ${buildPackages.zip}/bin/zip "$out/binaries.zip" \ - hypervisor image.elf + * ${apps.dhall-to-yaml.program} < ${ ./sotest_nova_config.dhall } > "$out/sotest_config.yaml" diff --git a/tests/solo5/default.nix b/tests/solo5/default.nix index 3a27fdd..fe75ed0 100644 --- a/tests/solo5/default.nix +++ b/tests/solo5/default.nix @@ -29,7 +29,7 @@ let tests = [ { name = "multi"; - sotest = true; + sotest = false; testConfig = "${./.}/solo5.dhall"; testInputs = map genodeMake [ "app/ping" ] ++ (map genodeDepot [ "ram_block" diff --git a/tests/test-wrapper.dhall b/tests/test-wrapper.dhall index 91eb074..f060266 100644 --- a/tests/test-wrapper.dhall +++ b/tests/test-wrapper.dhall @@ -27,6 +27,12 @@ let wrapHarness "LOG" (Some "SOTEST") (Some "unlabeled") + , { service = + { name = "LOG" + , label = Init.LabelSelector.Type.Last "unlabeled" + } + , route = Init.Route.Type.Parent { label = Some "unlabeled" } + } , Init.ServiceRoute.parent "IO_MEM" , Init.ServiceRoute.parent "IO_PORT" , Init.ServiceRoute.parent "IRQ" diff --git a/tests/tftp_rom.dhall b/tests/tftp_rom.dhall new file mode 100644 index 0000000..121c2c8 --- /dev/null +++ b/tests/tftp_rom.dhall @@ -0,0 +1,153 @@ +-- 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 label = λ(_ : Text) → { local = _, route = _ } : Child.Attributes.Label + +let benchmarkAttrs = + Child.Attributes::{ + , binary = "rom_benchmark" + , config = + { attributes = toMap { interations = "8" } + , content = + Prelude.List.map + Text + XML.Type + ( λ(label : Text) + → XML.element + { name = "rom" + , attributes = XML.emptyAttributes + , content = [ XML.text label ] + } + ) + [ "rom_benchmark" ] + } + } + +let test = + Genode.Init::{ + , children = toMap + { acpi_drv = + Child.flat + Child.Attributes::{ + , binary = "acpi_drv" + , resources = Resources::{ + , caps = 400 + , ram = Genode.units.MiB 4 + , constrainPhys = True + } + , provides = [ "Platform", "Acpi" ] + , romReports = [ label "acpi", label "smbios_table" ] + , routes = + [ ServiceRoute.parent "IRQ" + , ServiceRoute.parent "IO_MEM" + , ServiceRoute.parent "IO_PORT" + ] + } + , nic_drv = + Child.flat + Child.Attributes::{ + , binary = "ipxe_nic_drv" + , exitPropagate = True + , provides = [ "Nic" ] + , resources = Resources::{ + , caps = 128 + , ram = Genode.units.MiB 4 + } + , routes = + [ ServiceRoute.parent "Timer" + , ServiceRoute.parent "IO_MEM" + , ServiceRoute.parent "IO_PORT" + , ServiceRoute.childLabel + "Platform" + "platform_drv" + (None Text) + (Some "ipxe_nic_drv") + ] + } + , platform_drv = + Child.flat + Child.Attributes::{ + , binary = "platform_drv" + , resources = Resources::{ + , caps = 800 + , ram = Genode.units.MiB 4 + , constrainPhys = True + } + , reportRoms = [ label "acpi" ] + , provides = [ "Platform", "Acpi" ] + , routes = + [ ServiceRoute.parent "Timer" + , ServiceRoute.parent "IRQ" + , ServiceRoute.parent "IO_MEM" + , ServiceRoute.parent "IO_PORT" + ] + , config = Init.Config::{ + , content = + [ XML.text + '' + + '' + ] + } + } + , tftp_rom = + Child.flat + Child.Attributes::{ + , binary = "tftp_rom" + , config = Init.Config::{ + , attributes = toMap { verbose = "yes", dhcp = "yes" } + , content = + [ XML.text + '' + + '' + ] + } + , exitPropagate = True + , provides = [ "ROM" ] + , resources = Resources::{ ram = Genode.units.MiB 32 } + , routes = + [ ServiceRoute.child "Nic" "nic_drv" + , ServiceRoute.parent "Timer" + ] + } + , benchmark = + Child.flat + ( benchmarkAttrs + ⫽ { exitPropagate = True + , routes = + [ { service = + { name = "ROM" + , label = Init.LabelSelector.Type.Last "ld.lib.so" + } + , route = Init.Route.parent + } + , ServiceRoute.child "ROM" "tftp_rom" + , ServiceRoute.parent "Timer" + ] + } + ) + } + } + +in Test::{ + , children = toMap + { baseline = Child.flat benchmarkAttrs + , test = Init.toChild test Init.Attributes.default + } + } diff --git a/tests/tftp_rom.nix b/tests/tftp_rom.nix new file mode 100644 index 0000000..40f6aad --- /dev/null +++ b/tests/tftp_rom.nix @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: CC0-1.0 + +{ buildPackages, testEnv, pkgs, ... }: +with pkgs; + +let tftpRoot = pkgs.rom_benchmark; +in testEnv.mkTest { + name = "tftp_rom"; + meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ]; + + testConfig = ./tftp_rom.dhall; + testInputs = [ pkgs.tftp_rom pkgs.rom_benchmark ] + ++ map pkgs.genodeSources.depot [ + "acpi_drv" + "ipxe_nic_drv" + "platform_drv" + "report_rom" + ]; + testScript = '' + run_genode_until {SOTEST END} 60 + ''; + + qemuArgs = [ + "-netdev user,id=n0,restrict=on,tftp=${tftpRoot}" + "-device e1000,netdev=n0" + # "-object filter-dump,id=f0,netdev=n0,file=qemu.pcap" + ]; + + sotest = true; + extraSotest = [ pkgs.rom_benchmark ]; +}