From 6d6d585f0f8b43e0aadeca26e1f78ce034111899 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Tue, 10 Mar 2020 13:33:53 +0100 Subject: [PATCH] Refactor of packaging and testing - Remove manifests from Dhall configurations and mix all test inputs to generate test ROM maps. - All loader and timer drivers are name ld.lib.so and timer_drv. - Replace packages of multiple Genode Labs targets with functions to build individual targets. These packages are not explicitly specified unless they require inputs from the source ports or extra nativeBuildInputs. - Add support for building from Genode world repository. --- apps/generate-manifest/default.nix | 25 +-- apps/hw-image/default.nix | 10 +- apps/linux-image/default.nix | 2 - apps/nova-image/default.nix | 10 +- apps/render-init/default.nix | 2 +- compositions/pc-drivers.dhall | 2 +- flake.lock | 13 +- flake.nix | 10 - packages/default.nix | 127 ++++-------- packages/genodelabs/capslock.patch | 21 -- packages/genodelabs/default.nix | 301 ++++++++++++----------------- packages/genodelabs/ports.nix | 40 ++++ packages/genodelabs/sources.nix | 10 - packages/genodelabs/targets.nix | 38 ++++ tests/driver-hw-config.dhall | 38 ---- tests/driver-hw.nix | 17 +- tests/driver-linux-config.dhall | 41 ---- tests/driver-linux.nix | 8 +- tests/driver-nova-config.dhall | 38 ---- tests/driver-nova.nix | 17 +- tests/driver_manager.dhall | 193 +++++++++++------- tests/driver_manager.nix | 34 ++-- tests/driver_manager.rom.dhall | 73 ------- tests/log.dhall | 7 +- tests/log.nix | 2 +- tests/noux.dhall | 16 +- tests/noux.nix | 6 +- tests/pci.dhall | 12 +- tests/pci.nix | 9 +- tests/rtc.dhall | 8 +- tests/rtc.nix | 2 +- tests/signal.dhall | 7 +- tests/signal.nix | 2 +- tests/solo5/blk.dhall | 10 +- tests/solo5/boot-wrapper.dhall | 10 - tests/solo5/default.nix | 23 ++- tests/solo5/net.dhall | 12 +- tests/solo5/net_2if.dhall | 13 +- tests/solo5/simple.dhall | 8 +- tests/solo5/time.dhall | 10 +- tests/sotest-wrapper.dhall | 29 --- tests/test-wrapper.dhall | 63 ++++++ 42 files changed, 545 insertions(+), 774 deletions(-) delete mode 100644 packages/genodelabs/capslock.patch create mode 100644 packages/genodelabs/ports.nix delete mode 100644 packages/genodelabs/sources.nix create mode 100644 packages/genodelabs/targets.nix delete mode 100644 tests/driver-hw-config.dhall delete mode 100644 tests/driver-linux-config.dhall delete mode 100644 tests/driver-nova-config.dhall delete mode 100644 tests/driver_manager.rom.dhall delete mode 100644 tests/solo5/boot-wrapper.dhall delete mode 100644 tests/sotest-wrapper.dhall create mode 100644 tests/test-wrapper.dhall diff --git a/apps/generate-manifest/default.nix b/apps/generate-manifest/default.nix index c32c458..7c5605c 100644 --- a/apps/generate-manifest/default.nix +++ b/apps/generate-manifest/default.nix @@ -15,26 +15,9 @@ writeScriptBin "generate-manifest" '' echo \'$root\' is not an existing directory >> /dev/stderr exit 1 fi + set -eu - find="${findutils}/bin/find" - echo -n '{' - if [ -d "$root/bin" ]; then - echo -n ',bin = {' - find $root/bin/ -type f -printf '%f "%p"\n' \ - | awk '{print ", "gensub(/\..*/, "", 1, $1)"={mapKey= \""$1"\",mapValue ="$2"}"}' - echo -n '}' - fi - if [ -d "$root/lib" ]; then - echo -n ',lib = {' - find $root/lib/ -type f -name '*.lib.so' -printf '%f "%p"\n' \ - | awk '{print ", "gensub(/\..*/, "", 1, $1)"={mapKey=\""$1"\",mapValue="$2"}"}' - echo -n '}' - fi - if [ -d "$root/tar" ]; then - echo -n ',tar = {' - find $root/tar/ -type f -name '*.tar' -printf '%f "%p"\n' \ - | awk '{print ""gensub(/\..*/, "", 1, $1)"={mapKey=\""$1"\",mapValue="$2"}" }' - echo -n '}' - fi - echo '}' + echo -n '[' + find $root/ -type f -printf ',{mapKey= "%f",mapValue="%p"}' + echo -n ']' '' diff --git a/apps/hw-image/default.nix b/apps/hw-image/default.nix index 65c83a4..b86d7a4 100644 --- a/apps/hw-image/default.nix +++ b/apps/hw-image/default.nix @@ -2,7 +2,7 @@ { stdenv, nixpkgs, dhallApps, packages }: -let inherit (packages) base-hw-pc; +let inherit (packages) genodeSources base-hw-pc; in nixpkgs.writeScriptBin "hw-image" (with nixpkgs.buildPackages; let inherit (stdenv) cc; @@ -33,7 +33,7 @@ in nixpkgs.writeScriptBin "hw-image" (with nixpkgs.buildPackages; # link final image $LD \ --strip-all \ - -T${base-hw-pc.src}/repos/base/src/ld/genode.ld \ + -T${genodeSources}/repos/base/src/ld/genode.ld \ -z max-page-size=0x1000 \ -Ttext=$link_address -gc-sections \ "$lib" "$TMPDIR/boot_modules.o" @@ -43,7 +43,7 @@ in nixpkgs.writeScriptBin "hw-image" (with nixpkgs.buildPackages; ${dhallApps.dhall.program} text \ <<< "(env:DHALL_GENODE).Init.render ($@).config" \ | ${nixpkgs.buildPackages.libxml2}/bin/xmllint \ - -schema ${packages.genode-sources}/repos/os/src/init/config.xsd - \ + -schema ${packages.genodeSources}/repos/os/src/init/config.xsd - \ | sed 's/>/>/g' \ > $TMPDIR/config @@ -51,8 +51,8 @@ in nixpkgs.writeScriptBin "hw-image" (with nixpkgs.buildPackages; <<< "${../insert-config-rom.dhall} \"$TMPDIR/config\" ($@).rom" \ > "$TMPDIR/modules.dhall" - build_core "''${CORE_OBJ:-${base-hw-pc}/lib/core-hw-pc.o}" "$TMPDIR/modules.dhall" 0xffffffc000000000 > core.elf - build_core "''${BOOTSTRAP_OBJ:-${base-hw-pc}/lib/bootstrap-hw-pc.o}" "${ + build_core "''${CORE_OBJ:-${base-hw-pc.coreObj}}" "$TMPDIR/modules.dhall" 0xffffffc000000000 > core.elf + build_core "''${BOOTSTRAP_OBJ:-${base-hw-pc.bootstrapObj}}" "${ ../to-rom.dhall } \"core.elf\" \"./core.elf\"" 0x00200000 '') diff --git a/apps/linux-image/default.nix b/apps/linux-image/default.nix index 3810483..d8e9e45 100644 --- a/apps/linux-image/default.nix +++ b/apps/linux-image/default.nix @@ -7,8 +7,6 @@ nixpkgs.writeScriptBin "linux-image" (with nixpkgs.buildPackages; '' set -eu export DHALL_PRELUDE=''${DHALL_PRELUDE:-${packages.dhallPrelude}/package.dhall} export DHALL_GENODE=''${DHALL_GENODE:-${packages.dhallGenode}/package.dhall} - export BASE_LINUX_MANIFEST=''${BASE_LINUX_MANIFEST:-${packages.base-linux.manifest}} - export OS_MANIFEST=''${OS_MANIFEST:-${packages.os.manifest}} ${dhallApps.dhall.program} text <<< "${./script.dhall} ($@)" > boot.sh source boot.sh rm boot.sh diff --git a/apps/nova-image/default.nix b/apps/nova-image/default.nix index 7da17c0..5f3f8d2 100644 --- a/apps/nova-image/default.nix +++ b/apps/nova-image/default.nix @@ -2,7 +2,7 @@ { stdenv, nixpkgs, dhallApps, packages }: -let inherit (packages) base-nova; +let inherit (packages) genodeSources base-nova; in nixpkgs.writeScriptBin "nova-image" (with nixpkgs.buildPackages; let inherit (stdenv) cc; @@ -22,7 +22,7 @@ in nixpkgs.writeScriptBin "nova-image" (with nixpkgs.buildPackages; ${dhallApps.dhall.program} text \ <<< "(env:DHALL_GENODE).Init.render ($@).config" \ | ${nixpkgs.buildPackages.libxml2}/bin/xmllint \ - -schema ${packages.genode-sources}/repos/os/src/init/config.xsd - \ + -schema ${packages.genodeSources}/repos/os/src/init/config.xsd - \ | sed 's/>/>/g' \ > $TMPDIR/config @@ -37,10 +37,10 @@ in nixpkgs.writeScriptBin "nova-image" (with nixpkgs.buildPackages; # link final image $LD --strip-all \ - -T${base-nova.src}/repos/base/src/ld/genode.ld \ - -T${base-nova.src}/repos/base-nova/src/core/core-bss.ld \ + -T${genodeSources}/repos/base/src/ld/genode.ld \ + -T${genodeSources}/repos/base-nova/src/core/core-bss.ld \ -z max-page-size=0x1000 \ -Ttext=0x100000 -gc-sections \ - "''${CORE_OBJ:-${base-nova}/lib/core-nova.o}" "$TMPDIR/boot_modules.o" + "''${CORE_OBJ:-${base-nova.coreObj}}" "$TMPDIR/boot_modules.o" cat a.out '') diff --git a/apps/render-init/default.nix b/apps/render-init/default.nix index 8fb0a28..1317c0a 100644 --- a/apps/render-init/default.nix +++ b/apps/render-init/default.nix @@ -11,7 +11,7 @@ nixpkgs.writeScriptBin "render-init" (with nixpkgs.buildPackages; '' <<< "(env:DHALL_GENODE).Init.render ($(cat))" \ | ${nixpkgs.buildPackages.libxml2}/bin/xmllint \ -format \ - -schema ${packages.genode-sources}/repos/os/src/init/config.xsd \ + -schema ${packages.genodeSources}/repos/os/src/init/config.xsd \ - \ | sed 's/>/>/g' '') diff --git a/compositions/pc-drivers.dhall b/compositions/pc-drivers.dhall index a931a12..5982ada 100644 --- a/compositions/pc-drivers.dhall +++ b/compositions/pc-drivers.dhall @@ -69,7 +69,7 @@ let drivers = "Report" (Some label) (Some label) - + in [ routeReportToParent "acpi" , routeReportToParent "pci_devices" , routeReportToParent "usb_devices" diff --git a/flake.lock b/flake.lock index 9f67134..fae53d4 100644 --- a/flake.lock +++ b/flake.lock @@ -55,18 +55,21 @@ }, "genode-depot": { "info": { - "narHash": "sha256-7eL2MfGgeEaIwJXPc4LQ7pBa4JeGicm9th7onjKgzsE=" + "lastModified": 1584019323, + "narHash": "sha256-/ZWsNeLI90r77T1GHABWjY5vtYFKDCUL+Io9ljfKgMA=", + "revCount": 8 }, "inputs": { "nixpkgs": { "info": { - "narHash": "sha256-OnpEWzNxF/AU4KlqBXM2s5PWvfI5/BS6xQrPvkF5tO8=" + "lastModified": 1584015812, + "narHash": "sha256-oDj4g9nL3fp3xh0jAPZSHiucDxkLXA/rO3uM8L6kE0Y=" }, "inputs": {}, "locked": { - "owner": "edolstra", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "7f8d4b088e2df7fdb6b513bc2d6941f1d422a013", + "rev": "a3735dcbd7b2530ae3bcf73fd91e1ca6aa9449e7", "type": "github" }, "original": { @@ -77,7 +80,7 @@ }, "locked": { "ref": "master", - "rev": "8c2aafed45b4075e37f1cd93de0ebf93f38c83c3", + "rev": "025906c2146d81fb890532c6e46dbfda4cb38ede", "type": "git", "url": "https://git.sr.ht/~ehmry/genode-depot" }, diff --git a/flake.nix b/flake.nix index 0d8945b..7225c7f 100644 --- a/flake.nix +++ b/flake.nix @@ -34,21 +34,11 @@ dhallApps = dhall-haskell.apps.${localSystem}; }; - defaultPackage = with packages; - lib.mergeManifests [ - base-hw-pc - base-nova - base-linux - os - sotest-producer - ]; - devShell = legacyPackages.mkShell { nativeBuildInputs = [ dhall-haskell.packages.${localSystem}.dhall ]; shellHook = '' export DHALL_PRELUDE="${packages.dhallPrelude}/package.dhall" export DHALL_GENODE="${packages.dhallGenode}/package.dhall" - export MANIFEST="${defaultPackage}" ''; }; diff --git a/packages/default.nix b/packages/default.nix index a362e1b..4784402 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -17,24 +17,40 @@ let callPackage' = path: attrs: addManifest (legacyPackages.callPackages path attrs); - buildUpstream = let f = import ./genodelabs { nixpkgs = legacyPackages; }; - in args: addManifest (f args); + genodeLabs = import ./genodelabs { + nixpkgs = legacyPackages; + inherit addManifest; + }; + inherit (genodeLabs) buildUpstream; + + buildWorld = let + genodeWorld = legacyPackages.fetchFromGitHub { + owner = "genodelabs"; + repo = "genode-world"; + rev = "0ed545e55a90c39df23a86eb733961de71d56241"; + hash = "sha256-sirmUtLmZ5YnfLKrOvOBafnZW3UW+1LtkiGu85Ma820="; + }; + in attrs: + buildUpstream (attrs // { + postConfigure = + "echo REPOSITORIES += ${genodeWorld} >> build/etc/build.conf"; + }); in rec { - inherit (legacyPackages) stdenv; - - genode-sources = legacyPackages.callPackage ./genodelabs/sources.nix { }; + inherit (genodeLabs) genodeSources; base-hw-pc = buildUpstream { name = "base-hw-pc"; + outputs = [ "out" "coreObj" "bootstrapObj" ]; KERNEL = "hw"; BOARD = "pc"; targets = [ "bootstrap" "core" "timer" "lib/ld" ]; postInstall = '' - mkdir -p $out/lib - mv $out/bin/*.o $out/lib/ - mv $out/lib/ld-hw.lib.so $out/lib/ld.lib.so + mv $out/core-hw-pc.o $coreObj + mv $out/bootstrap-hw-pc.o $bootstrapObj + mv $out/ld-hw.lib.so $out/ld.lib.so + mv $out/hw_timer_drv $out/timer_drv ''; }; @@ -44,103 +60,30 @@ in rec { targets = [ "core" "timer" "lib/ld" ]; postInstall = '' mkdir -p $out/lib - mv $out/lib/ld-linux.lib.so $out/lib/ld.lib.so + mv $out/ld-linux.lib.so $out/lib/ld.lib.so + mv $out/linux_timer_drv $out/timer_drv ''; HOST_INC_DIR = legacyPackages.buildPackages.glibc.dev + "/include"; }; base-nova = buildUpstream { name = "base-nova"; + outputs = [ "out" "coreObj" ]; KERNEL = "nova"; targets = [ "core" "timer" "lib/ld" ]; postInstall = '' - mkdir -p $out/lib - mv $out/bin/*.o $out/lib/ - mv $out/lib/ld-nova.lib.so $out/lib/ld.lib.so + mv $out/core-nova.o $coreObj + mv $out/ld-nova.lib.so $out/ld.lib.so + mv $out/nova_timer_drv $out/timer_drv ''; }; - driversPc = let directoryBlacklist = [ "repos/dde_zircon" ]; - in buildUpstream { - name = "drivers"; - BOARD = "pc"; - targets = [ "drivers" ]; - ports = [ "dde_bsd" "dde_ipxe" "dde_linux" "libc" "openssl" "x86emu" ]; - preBuild = "find ${toString directoryBlacklist} -name target.mk -delete"; - }; + init = genodeSources.make "init"; - noux = buildUpstream { - name = "noux"; - targets = [ "noux" "lib/libc_noux" ]; - ports = [ "libc" ]; - }; - - os = let - directoryBlacklist = [ - "repos/dde_bsd" - "repos/dde_ipxe" - "repos/dde_linux" - "repos/dde_rump" - "repos/gems/src/app/mixer_gui_qt" - "repos/gems/src/server/http_block" - "repos/gems/src/server/terminal_mux" - "repos/libports" - "repos/ports" - ]; - in buildUpstream { - name = "os"; - patches = [ ./genodelabs/capslock.patch ]; - targets = [ "app" "init" "lib/vfs" "server" ]; - ports = [ "jitterentropy" "libc" "libpng" "libssh" "openssl" "stb" "zlib" ]; - preBuild = "find ${toString directoryBlacklist} -name target.mk -delete"; - nativeBuildInputs = with legacyPackages.buildPackages; [ bison flex ]; - }; - - vfs_lwip = buildUpstream { - name = "lwip"; - targets = [ "lib/vfs/lwip" ]; - ports = [ "lwip" ]; - }; - - vfs_rump = buildUpstream { - name = "vfs_rump"; - targets = [ "lib/vfs/rump" ]; - ports = [ "dde_rump" ]; - buildInputs = [ legacyPackages.buildPackages.zlib ]; - }; - - vfs_ttf = buildUpstream { - name = "vfs_ttf"; - targets = [ "lib/vfs/ttf" ]; - ports = [ "libc" "stb" ]; - }; - - virtualbox5 = buildUpstream { - name = "virtualbox5"; - targets = [ "virtualbox5" ]; - ports = [ "libc" "libiconv" "qemu-usb" "stdcxx" "virtualbox5" ]; - nativeBuildInputs = with legacyPackages.buildPackages; [ iasl yasm ]; - KERNEL = "nova"; - }; - - genodeTests = let - directoryBlacklist = [ - "repos/base-*" - "repos/base/src/test/sanitizer" - "repos/base/src/test/xml_generator" - "repos/gems/src/test/aes_cbc_4k" - "repos/gems/src/test/decorator_stress" - "repos/gems/src/test/text_painter" - "repos/gems/src/test/text_painter" - "repos/gems/src/test/tiled_wm" - "repos/libports" - "repos/ports" - ]; - in buildUpstream { - name = "genode-tests"; - preBuild = "find ${toString directoryBlacklist} -name target.mk -delete"; - targets = [ "test" ]; - ports = [ "libc" ]; + ssh_client = buildWorld { + name = "ssh_client"; + targets = [ "app/ssh_client" ]; + portInputs = with genodeSources.ports; [ libc libssh openssl zlib ]; }; bender = legacyPackages.buildPackages.callPackage ./bender { }; diff --git a/packages/genodelabs/capslock.patch b/packages/genodelabs/capslock.patch deleted file mode 100644 index aad957b..0000000 --- a/packages/genodelabs/capslock.patch +++ /dev/null @@ -1,21 +0,0 @@ -commit 6bc2bd3f4ac2c4e68d7d6dbee164a40b5a72638f -Author: Emery Hemingway -Date: Wed Feb 26 22:35:36 2020 +0100 - - Disable capslock/numlock requirements in driver_manager - - The capslock and numlock state ROMs introduce senseless complexity. - -diff --git a/repos/gems/src/app/driver_manager/main.cc b/repos/gems/src/app/driver_manager/main.cc -index 149911a717..afe62e8297 100644 ---- a/repos/gems/src/app/driver_manager/main.cc -+++ b/repos/gems/src/app/driver_manager/main.cc -@@ -662,8 +662,6 @@ void Driver_manager::Main::_generate_usb_drv_config(Reporter &usb_drv_config, - xml.attribute("ehci", true); - xml.attribute("ohci", _use_ohci); - xml.attribute("xhci", true); -- xml.attribute("capslock_led", "rom"); -- xml.attribute("numlock_led", "rom"); - xml.node("hid", [&] () { }); - xml.node("raw", [&] () { - xml.node("report", [&] () { xml.attribute("devices", true); }); diff --git a/packages/genodelabs/default.nix b/packages/genodelabs/default.nix index dbb5665..316e81e 100644 --- a/packages/genodelabs/default.nix +++ b/packages/genodelabs/default.nix @@ -1,10 +1,37 @@ -{ nixpkgs }: +{ nixpkgs, addManifest }: let - inherit (nixpkgs.genodeHeaders) version src; + genodeSources = let + inherit (nixpkgs) stdenv; + platform = stdenv.targetPlatform; - sourceForgeToolchain = - nixpkgs.buildPackages.callPackage ./toolchain.nix { }; + arch = with platform; + if isx86_64 then + "x86_64" + else + throw "unknown Genode arch for platform ${platform.system}"; + + toolPrefix = if platform.isx86 then + "genode-x86-" + else + throw "unknown tool prefix for Genode arch ${arch}"; + in stdenv.mkDerivation { + pname = "genode-sources"; + inherit (nixpkgs.genodeHeaders) src version; + nativeBuildInputs = with nixpkgs.buildPackages; [ expect gnumake tcl ]; + patches = [ ./init.xsd.patch ./svn-trust-server-cert.patch ]; + configurePhase = '' + patchShebangs ./tool + substituteInPlace repos/base/etc/tools.conf \ + --replace "/usr/local/genode/tool/19.05/bin/" "" + substituteInPlace tool/check_abi \ + --replace "exec nm" "exec ${toolPrefix}nm" + ''; + dontBuild = true; + installPhase = "cp -a . $out"; + }; + + sourceForgeToolchain = nixpkgs.buildPackages.callPackage ./toolchain.nix { }; stdenv' = nixpkgs.stdenvAdapters.overrideCC nixpkgs.stdenv sourceForgeToolchain; @@ -17,192 +44,114 @@ let else throw "unknown Genode arch for platform ${platform.system}"; - toolPrefix = if platform.isx86 then - "genode-x86-" - else - throw "unknown tool prefix for Genode arch ${arch}"; + preparePort = name: + { hash ? "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", ... }@args: + nixpkgs.buildPackages.stdenv.mkDerivation (args // { + outputHashMode = "recursive"; + outputHash = hash; + pname = name; + inherit (genodeSources) version; + + GIT_SSL_CAINFO = + "${nixpkgs.buildPackages.cacert}/etc/ssl/certs/ca-bundle.crt"; + VERBOSE = ""; + # need to build in verbose mode because errors are hidden + + impureEnvVars = stdenv'.lib.fetchers.proxyImpureEnvVars + ++ [ "GIT_PROXY_COMMAND" "SOCKS_SERVER" ]; + + dontUnpack = true; + dontConfigure = true; + + nativeBuildInputs = with nixpkgs.buildPackages; + [ bison flex gitMinimal glibc glibcLocales rsync wget which ] + ++ (args.nativeBuildInputs or [ ]); + + buildPhase = '' + runHook preBuild + export CONTRIB_DIR=$NIX_BUILD_TOP/contrib + mkdir $CONTRIB_DIR + ${genodeSources}/tool/ports/prepare_port $pname + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + rsync $CONTRIB_DIR/* $out/ \ + -lr --copy-unsafe-links \ + --exclude '*.git' \ + --exclude '*.svn' \ + --exclude '*.gz' \ + --exclude '*.xz' \ + + runHook postInstall + ''; + }); + + ports = + nixpkgs.lib.mapAttrs preparePort (import ./ports.nix nixpkgs.buildPackages); + + buildUpstream = { name, targets, portInputs ? [ ], nativeBuildInputs ? [ ] + , ... }@extraAttrs: - mkPort = { name, hash, nativeBuildInputs ? [ ] }: let - value = stdenv'.mkDerivation { + drv = stdenv'.mkDerivation (extraAttrs // { pname = name; - inherit src version; + inherit (genodeSources) version; + inherit targets; - outputHashMode = "recursive"; - outputHash = hash; + dontUnpack = true; nativeBuildInputs = with nixpkgs.buildPackages; - [ bison glibc flex gitMinimal subversion glibcLocales which wget ] - ++ nativeBuildInputs; + [ binutils bison flex stdenv.cc tcl which ] ++ nativeBuildInputs; - patches = [ ./svn-trust-server-cert.patch ]; + enableParallelBuilding = true; - configurePhase = '' + configurePhase = let + linkPorts = toString + (builtins.map (drv: " ln -sv ${drv}/* contrib/;") portInputs); + in '' runHook preConfigure - patchShebangs ./tool/ports + export CONTRIB_DIR=$NIX_BUILD_TOP/contrib + export BUILD_DIR=$NIX_BUILD_TOP/build + ${genodeSources}/tool/create_builddir ${arch} + substituteInPlace build/etc/build.conf \ + --replace "#REPOSITORIES" "REPOSITORIES" + mkdir $CONTRIB_DIR; ${linkPorts} runHook postConfigure ''; - buildPhase = '' - export CONTRIB_DIR=$out - ./tool/ports/prepare_port $pname + makeFlags = [ "-C build" ] ++ targets; + + installPhase = '' + runHook preInstall + find build/bin -name '*.xsd' -delete + find build/bin -follow -type f -exec install -Dt $out '{}' \; + runHook postInstall ''; + }); + in addManifest drv; - dontInstall = true; - - GIT_SSL_CAINFO = - "${nixpkgs.buildPackages.cacert}/etc/ssl/certs/ca-bundle.crt"; - - impureEnvVars = stdenv'.lib.fetchers.proxyImpureEnvVars - ++ [ "GIT_PROXY_COMMAND" "SOCKS_SERVER" ]; - - }; - in { inherit name value; }; - - portDrvs = with nixpkgs.buildPackages; builtins.listToAttrs (builtins.map mkPort [ - { - name = "stb"; - hash = "sha256-RQKF/H3wsKy6ZT9PLv4vzerJl+0Be2wqNjqsUBYZU6U="; - } - { - name = "libc"; - hash = "sha256-yx5jGJI1w6KAwS2JPHhWpPFEeEyOv7yfIeXLRgQM7l8="; - } - { - name = "x86emu"; - hash = "sha256-fKUab/HflrcZqzSk/cz/QimPtPILGwvXgHkwE4y2uQc="; - } - { - name = "lwip"; - hash = "sha256-1oOJoCME8N1nQKUxG7vRBFRtJ9MausrIfno91QchMEU="; - } - { - name = "dde_linux"; - hash = "sha256-9xD+pIjYeL9W/2HsOpJCGJs5+RgM2gmwxXC+h1Yc90Y="; - } - { - name = "dde_bsd"; - hash = "sha256-ZcF6L4maC1vB5IP1jR6L4CWlaNf5Qu4xVjqITK3Yt0w="; - } - { - name = "dde_rump"; - hash = "sha256-aU5s+sf9/bZxzSX7+9wNEn3693yxDJB/dNVWMLuJkQI="; - } - { - name = "dde_ipxe"; - hash = "sha256-UIwC0O5IlxNWQKBJYE9h5ekVWP18UTvejsgb1i6KHCs="; - } - { - name = "openssl"; - hash = "sha256-eZYdDT4L3R64mhUKGAiiQUOF9GgeEHDZlsDZbI4BM58="; - } - { - name = "libiconv"; - hash = "sha256-TN3cZAo7zq7OLXXB2lLxOnM5c98aA0GksE7ACrymVvE="; - } - { - name = "qemu-usb"; - hash = "sha256-awBouSz5MBBc9HuHZiZJK7jbabNSyqBQMX2NPXHvR0I="; - } - { - name = "stdcxx"; - hash = "sha256-hXRdT6f2prKsCXDSJ4HMF1MNaRh0/EoNMrJUBuHQeyI="; - } - { - name = "virtualbox5"; - hash = "sha256-VZPXyFLzLFCmxbbBqmZ9HP0y6E+1I+v/+Rt22IjlOrI="; - nativeBuildInputs = [ - iasl - libxslt - unzip - yasm - ]; - } - { - name = "expat"; - hash = "sha256-CCMxMn2DpzrIkW9WMBaX1T77T/GECy8pVlsT+BpbsQs="; - } - { - name = "jpeg"; - hash = "sha256-ZUMuNV9ltGqZhny6LAn/Do1ojbypnSHa9dfQ0ZVZhUE="; - } - { - name = "lz4"; - hash = "sha256-xYohPuOwqiFBHkqwP/q0fMafmWzMg4rt3qYZqO624wk="; - } - { - name = "mesa"; - hash = "sha256-ho8t+7jFzYPi8nmHi4usFNunwHsbSBdtvVOtAlbz9Oc="; - nativeBuildInputs = [ python ]; - } - { - name = "mupdf"; - hash = "sha256-7zl2DKFIPzQdX/poF0jxejn81OCWrh7QfTuNmtOA4WA="; - } - { - name = "jitterentropy"; - hash = "sha256-FnLuTDOCyQ9/jpQfx0vtyrbUymW7G3BuSM+NINKOxK4="; - } - { - name = "libpng"; - hash = "sha256-Y3DjI7m1kYGbHX8hRob3RYnTTTX4LteOt5Yqzlcq/tQ="; - } - { - name = "libssh"; - hash = "sha256-IjHv+cbvAU7RVcKJSvHJmG8ZDULpEAawr7snPzWdMsU="; - } - { - name = "zlib"; - hash = "sha256-gWv8RKlc3TacC4sHPKXyhqVDRkM6MIXuWLqEx5gHz7s="; - } - ]); - -in { name, targets, ports ? [ ], nativeBuildInputs ? [ ], ... }@extraAttrs: - -let ports' = builtins.map (name: builtins.getAttr name portDrvs) ports; - -in stdenv'.mkDerivation (extraAttrs // { - pname = name; - inherit version targets; - src = nixpkgs.fetchFromGitHub { - owner = "genodelabs"; - repo = "genode"; - rev = version; - sha256 = "0idk92ibrasla0y2xkrmyh49dx0nzg96gqkcmn6r3w5r3fdpsfjy"; + buildOverrides = import ./targets.nix { + inherit (nixpkgs) buildPackages; + inherit ports; }; - nativeBuildInputs = with nixpkgs.buildPackages; - [ binutils bison flex stdenv.cc tcl which ] ++ nativeBuildInputs; +in { + inherit buildUpstream; + genodeSources = genodeSources // { + make = target: + with builtins; + let + attrs = if hasAttr target buildOverrides then + getAttr target buildOverrides + else + { }; + in buildUpstream ({ + name = builtins.replaceStrings [ "/" ] [ "-" ] target; + targets = [ target ]; + } // attrs); + inherit ports; + }; - enableParallelBuilding = true; - - configurePhase = '' - runHook preConfigure - patchShebangs ./tool/check_abi - patchShebangs ./tool/create_builddir - substituteInPlace repos/base/etc/tools.conf \ - --replace "/usr/local/genode/tool/19.05/bin/" "" - substituteInPlace tool/check_abi \ - --replace "exec nm" "exec ${toolPrefix}nm" - ./tool/create_builddir ${arch} BUILD_DIR=build - substituteInPlace build/etc/build.conf \ - --replace "#REPOSITORIES" "REPOSITORIES" - runHook postConfigure - '' + (if ports != [ ] then - "mkdir contrib;" - + toString (builtins.map (drv: " ln -sv ${drv}/* contrib/;") ports') - else - ""); - - makeFlags = [ "-C build" ] ++ targets; - - installPhase = '' - runHook preInstall - find build/bin -name '*.xsd' -delete - find build/bin -name '*.lib.so' -exec install -Dt $out/lib '{}' \; -delete - find build/bin -exec install -Dt $out/bin '{}' \; - runHook postInstall - ''; - - passthru.ports = portDrvs; -}) +} diff --git a/packages/genodelabs/ports.nix b/packages/genodelabs/ports.nix new file mode 100644 index 0000000..2d68bc9 --- /dev/null +++ b/packages/genodelabs/ports.nix @@ -0,0 +1,40 @@ +# ports are superficially similar to Nix, but inferior in every way + +nativePkgs: +with nativePkgs; { + dde_bsd.hash = "sha256-2ilZs6JkcQAvU/sQYnHunGtGRZDt7qLTpKZxQxSOf2I="; + dde_ipxe.hash = "sha256-KAmDF2t+xKzkEjWZ1bvLO8O+IlaV0ImuFsd8SIC3UQw="; + dde_linux.hash = "sha256-a1oaYF5S8OazyCOu/Jq+YOfrN4Kyb4JesLs222Vanjc="; + dde_rump = { + hash = "sha256-Wr5otGkWEa+5xImsFHQzwap5LckNEbyWA/7xbNcOreI="; + nativeBuildInputs = [ subversion ]; + }; + expat.hash = "sha256-m4Q/rIeBCe/nxCksipQTAOCNSl2KYF4nItswXmhdKyk="; + jitterentropy.hash = "sha256-6KS732GxtUMz0xPYKtshdn039DgdJq11vTDQesZn4Ds="; + jpeg.hash = "sha256-NyO72pMphX/QyPJl5CqX/gJbDhEIwCYbXf18HQBaFEI="; + libc = { + hash = "sha256-xAydMqf2+OTNt7nMUk0KTTil7sIIWGvn0Ytmepkc3rI="; + nativeBuildInputs = [ buildPackages.gcc subversion ]; + }; + libiconv.hash = "sha256-3PWJJg0rQTa789Jb5RnuHN0nfBKFnd0g+J7Vk7uXn5c="; + libpng.hash = "sha256-bAUkafClnl+BDv0X2xs1iY4rlHVHkGxnb7UfPkCSeds="; + libssh.hash = "sha256-Z/1YdhISh2kqBjWiTOLkS+usoeeekJvAuYrVUgpxnQM="; + lighttpd.hash = "sha256-aBClCnOfbPSgisCTHquNhXAzkeslFp0ckK/lazr9AoE="; + lwip.hash = "sha256-V0Lo4DcY/Ai60kQmYB92BVlNX+QRLsymM5unXAvP0VI="; + lz4.hash = "sha256-Ndpv4NmZTeB737l2ywLrnXoqKzyCaBFMZl7ULfr14lY="; + mesa = { + hash = "sha256-vkVbWFKO9OXOb8sEhkCL9x4gxxXjRhM41WXsB7YL/4Q="; + nativeBuildInputs = [ python ]; + }; + mupdf.hash = "sha256-AQwnVdHHWmqnHKvG3+I9zXUoC5IHD0MtS5mRh9u/V+o="; + openssl.hash = "sha256-VMMzzaSw17SMETAYwGYNgMDPPgDpMjgrPnhMV8/Pn8o="; + qemu-usb.hash = "sha256-PilJvNrJfz4iHj//mmARN47SVcA6+PTey/auTuQcs88="; + stb.hash = "sha256-9LSH1i8jcEvjRAmTvgtK+Axy9hO7uiSzmSgBvs0zkTc="; + stdcxx.hash = "sha256-Pec6B3ziRDRGFia0/XyeA3fo6fyevC0LynKU4xa8weI="; + virtualbox5 = { + hash = "sha256-UEJTSD+jWc1arZ4ODqbfzM092UMZDiQlkbysxBdFE9w="; + nativeBuildInputs = [ iasl libxslt unzip yasm ]; + }; + x86emu.hash = "sha256-Q/fOQjbU0Frtkj+f2rSKuYRSEIk4s569qf3UaTbElLY="; + zlib.hash = "sha256-bxTalPJBSs5yEMO2gFKvoR1PadepmkFGt6jcSZN/fgE="; +} diff --git a/packages/genodelabs/sources.nix b/packages/genodelabs/sources.nix deleted file mode 100644 index c1267fc..0000000 --- a/packages/genodelabs/sources.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ stdenv, genodeHeaders }: - -stdenv.mkDerivation { - pname = "genode-sources"; - inherit (genodeHeaders) version src; - patches = [ ./init.xsd.patch ./svn-trust-server-cert.patch ]; - dontConfigure = true; - dontBuild = true; - installPhase = "cp -a . $out"; -} diff --git a/packages/genodelabs/targets.nix b/packages/genodelabs/targets.nix new file mode 100644 index 0000000..de7eb50 --- /dev/null +++ b/packages/genodelabs/targets.nix @@ -0,0 +1,38 @@ +{ buildPackages, ports }: + +with ports; + +{ + "app/lighttpd".portInputs = [ libc lighttpd openssl zlib ]; + + "drivers/framebuffer/intel" = { + BOARD = "pc"; + portInputs = [ dde_linux ]; + }; + + "drivers/framebuffer/vesa" = { + BOARD = "pc"; + portInputs = [ x86emu ]; + }; + + "drivers/usb".portInputs = [ dde_linux ]; + + "lib/vfs/lwip".portInputs = [ lwip ]; + "lib/vfs/ttf".portInputs = [ libc stb ]; + "lib/vfs/rump" = { + portInputs = [ dde_rump ]; + buildInputs = [ buildPackages.zlib ]; + }; + + noux = { + targets = [ "noux" "lib/libc_noux" ]; + portInputs = [ libc ]; + }; + + virtualbox5 = { + KERNEL = "nova"; + portInputs = [ libc libiconv qemu-usb stdcxx virtualbox5 ]; + nativeBuildInputs = with buildPackages; [ iasl yasm ]; + }; + +} diff --git a/tests/driver-hw-config.dhall b/tests/driver-hw-config.dhall deleted file mode 100644 index 6454580..0000000 --- a/tests/driver-hw-config.dhall +++ /dev/null @@ -1,38 +0,0 @@ --- SPDX-License-Identifier: CC0-1.0 - -let Genode = env:DHALL_GENODE - -let Init = Genode.Init - -let Child = Init.Child - -let wrapHarness - : Init.Type → Child.Type - = env:DHALL_WRAP_HARNESS ? ./sotest-wrapper.dhall - -in λ(boot : Genode.Boot.Type) - → { config = - Init::{ - , children = - [ { mapKey = "timer" - , mapValue = - Child.flat - Child.Attributes::{ - , binary = "hw_timer_drv" - , provides = [ "Timer" ] - } - } - , { mapKey = "harness", mapValue = wrapHarness boot.config } - ] - } - , rom = - let manifest = env:MANIFEST - - in Genode.Boot.toRomPaths - [ manifest.base-hw-pc.bin.hw_timer_drv - , manifest.base-hw-pc.lib.ld - , manifest.os.bin.init - , manifest.sotest-producer.bin.sotest-harness - ] - # boot.rom - } diff --git a/tests/driver-hw.nix b/tests/driver-hw.nix index 93ec8ab..b8d8fb0 100644 --- a/tests/driver-hw.nix +++ b/tests/driver-hw.nix @@ -34,20 +34,19 @@ let ''; }; - defaultScript = ''run_genode_until {[init] child "harness" exited with exit value 0} 60''; + defaultScript = + ''run_genode_until {[init] child "harness" exited with exit value 0} 60''; - mkTest = { name ? "unamed", testScript ? defaultScript, testConfig, testInputs ? [ ] - , testEnv ? { }, qemuArgs ? [], ... - }@t: + mkTest = { name ? "unamed", testScript ? defaultScript, testConfig + , testInputs ? [ ], testEnv ? { }, qemuArgs ? [ ], ... }@t: let - testConfig' = "${./driver-hw-config.dhall} ${testConfig}"; manifest = lib.mergeManifests (with testPkgs; - [ base-hw-pc os sotest-producer ] + [ base-hw-pc (genodeSources.make "init") sotest-producer ] ++ testInputs); + testConfig' = "${./test-wrapper.dhall} ${testConfig} (toMap ${manifest})"; testEnv' = { DHALL_PRELUDE = "${testPkgs.dhallPrelude}/package.dhall"; DHALL_GENODE = "${testPkgs.dhallGenode}/package.dhall"; - DHALL_WRAP_HARNESS = ./sotest-wrapper.dhall; MANIFEST = manifest; XDG_CACHE_HOME = "/tmp"; } // testEnv; @@ -142,8 +141,8 @@ let iso = apps.hw-iso.function testEnv' testConfig'; - xml = hostPkgs.runCommand (name + ".config") testEnv' '' - ${apps.render-init.program} <<< "(${testConfig'}).config" > $out''; + xml = hostPkgs.runCommand (name + ".config") testEnv' + ''${apps.render-init.program} <<< "(${testConfig'}).config" > $out''; sotest = hostPkgs.runCommand "hw-${name}-sotest" testEnv' '' cp "${testPkgs.bender}" bender diff --git a/tests/driver-linux-config.dhall b/tests/driver-linux-config.dhall deleted file mode 100644 index a475c16..0000000 --- a/tests/driver-linux-config.dhall +++ /dev/null @@ -1,41 +0,0 @@ --- SPDX-License-Identifier: CC0-1.0 -let Genode = env:DHALL_GENODE - -let Init = Genode.Init - -let Child = Init.Child - -let wrapHarness - : Init.Type → Child.Type - = env:DHALL_WRAP_HARNESS ? ./sotest-wrapper.dhall - -let Child = Genode.Init.Child - -in λ(boot : Genode.Boot.Type) - → { config = - Genode.Init::{ - , children = - [ { mapKey = "timer" - , mapValue = - Child.flat - Child.Attributes::{ - , binary = "linux_timer_drv" - , provides = [ "Timer" ] - } - } - , { mapKey = "harness", mapValue = wrapHarness boot.config } - ] - } - , rom = - let manifest = env:MANIFEST - - in Genode.BootModules.toRomPaths - [ manifest.base-linux.bin.core-linux - , manifest.base-linux.bin.linux_timer_drv - , manifest.base-linux.lib.ld - , manifest.os.bin.init - , manifest.sotest-producer.bin.sotest-harness - ] - # boot.rom - : Genode.BootModules.Type - } diff --git a/tests/driver-linux.nix b/tests/driver-linux.nix index 36d7bcc..cac0821 100644 --- a/tests/driver-linux.nix +++ b/tests/driver-linux.nix @@ -38,13 +38,13 @@ let , env ? { }, ... }: with testPkgs; let - testConfig' = "${./driver-linux-config.dhall} ${testConfig}"; + manifest = lib.mergeManifests + (with testPkgs; [ base-linux init sotest-producer ] ++ testInputs); + testConfig' = "${./test-wrapper.dhall} ${testConfig} (toMap ${manifest})"; env' = { DHALL_PRELUDE = "${testPkgs.dhallPrelude}/package.dhall"; DHALL_GENODE = "${testPkgs.dhallGenode}/package.dhall"; - DHALL_WRAP_HARNESS = ./sotest-wrapper.dhall; - MANIFEST = lib.mergeManifests (with testPkgs; - [ base-linux os sotest-producer ] ++ testInputs); + MANIFEST = manifest; XDG_CACHE_HOME = "/tmp"; } // env; diff --git a/tests/driver-nova-config.dhall b/tests/driver-nova-config.dhall deleted file mode 100644 index 57b66d7..0000000 --- a/tests/driver-nova-config.dhall +++ /dev/null @@ -1,38 +0,0 @@ --- SPDX-License-Identifier: CC0-1.0 - -let Genode = env:DHALL_GENODE - -let Init = Genode.Init - -let Child = Init.Child - -let wrapHarness - : Init.Type → Child.Type - = env:DHALL_WRAP_HARNESS ? ./sotest-wrapper.dhall - -in λ(boot : Genode.Boot.Type) - → { config = - Init::{ - , children = - [ { mapKey = "timer" - , mapValue = - Child.flat - Child.Attributes::{ - , binary = "nova_timer_drv" - , provides = [ "Timer" ] - } - } - , { mapKey = "harness", mapValue = wrapHarness 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 - , manifest.sotest-producer.bin.sotest-harness - ] - # boot.rom - } diff --git a/tests/driver-nova.nix b/tests/driver-nova.nix index 2e2d064..71bbe5b 100644 --- a/tests/driver-nova.nix +++ b/tests/driver-nova.nix @@ -34,20 +34,19 @@ let ''; }; - defaultScript = ''run_genode_until {[init] child "harness" exited with exit value 0} 60''; + defaultScript = + ''run_genode_until {[init] child "harness" exited with exit value 0} 60''; - mkTest = { name ? "unamed", testScript ? defaultScript, testConfig, testInputs ? [ ] - , testEnv ? { }, qemuArgs ? [], ... - }@t: + mkTest = { name ? "unamed", testScript ? defaultScript, testConfig + , testInputs ? [ ], testEnv ? { }, qemuArgs ? [ ], ... }@t: let - testConfig' = "${./driver-nova-config.dhall} ${testConfig}"; manifest = lib.mergeManifests (with testPkgs; - [ base-nova os sotest-producer ] + [ base-nova (genodeSources.make "init") sotest-producer ] ++ testInputs); + testConfig' = "${./test-wrapper.dhall} ${testConfig} (toMap ${manifest})"; testEnv' = { DHALL_PRELUDE = "${testPkgs.dhallPrelude}/package.dhall"; DHALL_GENODE = "${testPkgs.dhallGenode}/package.dhall"; - DHALL_WRAP_HARNESS = ./sotest-wrapper.dhall; MANIFEST = manifest; XDG_CACHE_HOME = "/tmp"; } // testEnv; @@ -143,8 +142,8 @@ let iso = apps.nova-iso.function testEnv' "${testConfig'}"; - xml = hostPkgs.runCommand (name + ".config") testEnv' '' - ${apps.render-init.program} <<< "(${testConfig'}).config" > $out''; + xml = hostPkgs.runCommand (name + ".config") testEnv' + ''${apps.render-init.program} <<< "(${testConfig'}).config" > $out''; sotest = hostPkgs.runCommand "nova-${name}-sotest" testEnv' '' cp "${testPkgs.bender}" bender diff --git a/tests/driver_manager.dhall b/tests/driver_manager.dhall index dd004cb..5b511d5 100644 --- a/tests/driver_manager.dhall +++ b/tests/driver_manager.dhall @@ -22,77 +22,136 @@ let childRomRoute = → λ(from : Text) → ServiceRoute.childLabel "ROM" child (Some from) (None Text) -let label = \(_ : Text) -> { local = _, route = _ } +let label = λ(_ : Text) → { local = _, route = _ } -in Init::{ - , verbose = True - , children = - toMap - { , drivers = - Init.toChild - drivers - Init.Attributes::{ - , provides = [ "Block", "Framebuffer", "Input" ] - , resources = Init.Resources::{ ram = Genode.units.MiB 4 } - , romReports = [ label "block_devices" ] - , routes = - [ parentRomRoute - "managed/input_filter" - "input_filter.config" - , parentRomRoute " numlock_remap" "numlock_remap.config" - , childRomRoute "dynamic_rom" "capslock" - , childRomRoute "dynamic_rom" "numlock" - , childRomRoute "dynamic_rom" "system" - , ServiceRoute.child "Report" "_report_rom" - , ServiceRoute.parent "Timer" - , Genode.Init.ServiceRoute.parent "IRQ" - , Genode.Init.ServiceRoute.parent "IO_MEM" - , Genode.Init.ServiceRoute.parent "IO_PORT" - ] - } - , dynamic_rom = - Child.flat - Child.Attributes::{ - , binary = "dynamic_rom" - , resources = Resources::{ ram = Genode.units.MiB 4 } - , provides = [ "ROM" ] - , config = - Genode.Init.Config::{ - , content = - [ Genode.Prelude.XML.text - '' - - - - - - - '' +in Genode.Boot::{ + , config = + Init::{ + , verbose = True + , children = + toMap + { drivers = + Init.toChild + drivers + Init.Attributes::{ + , provides = [ "Block", "Framebuffer", "Input" ] + , resources = Init.Resources::{ ram = Genode.units.MiB 4 } + , romReports = [ label "block_devices" ] + , routes = + [ parentRomRoute + "managed/input_filter" + "input_filter.config" + , parentRomRoute " numlock_remap" "numlock_remap.config" + , childRomRoute "dynamic_rom" "capslock" + , childRomRoute "dynamic_rom" "numlock" + , childRomRoute "dynamic_rom" "system" + , ServiceRoute.child "Report" "_report_rom" + , ServiceRoute.parent "Timer" + , Genode.Init.ServiceRoute.parent "IRQ" + , Genode.Init.ServiceRoute.parent "IO_MEM" + , Genode.Init.ServiceRoute.parent "IO_PORT" ] } - } - , test-driver_manager = - Child.flat - Child.Attributes::{ - , binary = "test-driver_manager" - , config = - Init.Config::{ - , content = - [ Genode.Prelude.XML.text - '' - - - - '' + , dynamic_rom = + Child.flat + Child.Attributes::{ + , binary = "dynamic_rom" + , resources = Resources::{ ram = Genode.units.MiB 4 } + , provides = [ "ROM" ] + , config = + Genode.Init.Config::{ + , content = + [ Genode.Prelude.XML.text + '' + + + + + + + '' + ] + } + } + , test-driver_manager = + Child.flat + Child.Attributes::{ + , binary = "test-driver_manager" + , config = + Init.Config::{ + , content = + [ Genode.Prelude.XML.text + '' + + + + '' + ] + } + , reportRoms = [ label "block_devices" ] + , routes = + [ ServiceRoute.child "Block" "drivers" + , ServiceRoute.child "Framebuffer" "drivers" + , ServiceRoute.child "Input" "drivers" ] } - , reportRoms = [ label "block_devices" ] - , routes = - [ - , ServiceRoute.child "Block" "drivers" - , ServiceRoute.child "Framebuffer" "drivers" - , ServiceRoute.child "Input" "drivers" - ] + } + } + , rom = + Genode.Boot.toRomTexts + ( toMap + { capslock = "" + , numlock = "" + , usb_policy = "" } - } + # [ { mapKey = + "fb_drv.config" + , mapValue = + '' + + + + '' + } + , { mapKey = + "input_filter.config" + , mapValue = + '' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + '' + } + ] + ) } diff --git a/tests/driver_manager.nix b/tests/driver_manager.nix index c766f2a..de4ebc7 100644 --- a/tests/driver_manager.nix +++ b/tests/driver_manager.nix @@ -7,21 +7,33 @@ testEnv.mkTest { name = "driver_manager"; meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ]; testEnv = { drivers = ./../compositions/pc-drivers.dhall; }; - testInputs = (with pkgs; [ genodeTests driversPc ]) ++ (with depot; [ - boot_fb_drv - intel_fb_drv - usb_drv - vesa_drv + testInputs = (map pkgs.genodeSources.make [ + "app/driver_manager" + "app/rom_reporter" + "drivers/acpi" + "drivers/ahci" + "drivers/framebuffer/boot" + "drivers/framebuffer/intel" + "drivers/framebuffer/vesa" + "drivers/input/spec/ps2" + "drivers/platform" + "drivers/rtc" + "drivers/usb" + "server/dynamic_rom" + "server/input_filter" + "server/report_rom" + "test/driver_manager" ]); + testScript = '' catch { exec dd if=/dev/zero of=hdd_disk.raw bs=1M count=32 } catch { exec ${hostPkgs.e2fsprogs}/bin/mke2fs -F bin/hdd_disk.raw } run_genode_until {.*all expected devices present and accessible.*} 120 - ''; - testConfig = '' - { config = ${./driver_manager.dhall} - , rom = ${./driver_manager.rom.dhall} - } ''; - qemuArgs = [ "-device ahci,id=ahci" "-drive id=hdd,file=hdd_disk.raw,format=raw,if=none" "-device ide-hd,drive=hdd,bus=ahci.1"]; + testConfig = ./driver_manager.dhall; + qemuArgs = [ + "-device ahci,id=ahci" + "-drive id=hdd,file=hdd_disk.raw,format=raw,if=none" + "-device ide-hd,drive=hdd,bus=ahci.1" + ]; } diff --git a/tests/driver_manager.rom.dhall b/tests/driver_manager.rom.dhall deleted file mode 100644 index d7d5fbc..0000000 --- a/tests/driver_manager.rom.dhall +++ /dev/null @@ -1,73 +0,0 @@ -let Genode = env:DHALL_GENODE - -let manifest = env:MANIFEST - -in Genode.Boot.toRomPaths - [ - , manifest.drivers.bin.acpi_drv - , manifest.drivers.bin.ahci_drv - , manifest.drivers.bin.platform_drv - , manifest.drivers.bin.ps2_drv - , manifest.drivers.bin.rtc_drv - , manifest.drivers.bin.usb_drv - , manifest.drivers.bin.vesa_fb_drv - , manifest.genode-tests.bin.test-driver_manager - , manifest.os.bin.driver_manager - , manifest.os.bin.dynamic_rom - , manifest.os.bin.input_filter - , manifest.os.bin.report_rom - , manifest.os.bin.rom_reporter - ] - # Genode.Boot.toRomTexts - ( toMap - { usb_policy = "" } - # [ { mapKey = - "fb_drv.config" - , mapValue = - '' - - - - '' - } - , { mapKey = - "input_filter.config" - , mapValue = - '' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - '' - } - ] - ) diff --git a/tests/log.dhall b/tests/log.dhall index c66c65d..5b70fa1 100644 --- a/tests/log.dhall +++ b/tests/log.dhall @@ -4,7 +4,8 @@ let Genode = env:DHALL_GENODE let Child = Genode.Init.Child -in { config = +in Genode.Boot::{ + , config = Genode.Init::{ , children = toMap @@ -22,8 +23,4 @@ in { config = } } } - , rom = - let manifest = env:MANIFEST - - in Genode.Boot.toRomPaths [ manifest.genode-tests.bin.test-log ] } diff --git a/tests/log.nix b/tests/log.nix index fea26e2..94fdd2c 100644 --- a/tests/log.nix +++ b/tests/log.nix @@ -8,6 +8,6 @@ testEnv.mkTest rec { meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ]; testConfig = ./log.dhall; - testInputs = [ pkgs.genodeTests ]; + testInputs = [ (pkgs.genodeSources.make "test/log") ]; testScript = "run_genode_until {Test done.} 120"; } diff --git a/tests/noux.dhall b/tests/noux.dhall index 5e597c0..2232e75 100644 --- a/tests/noux.dhall +++ b/tests/noux.dhall @@ -4,7 +4,8 @@ let Genode = env:DHALL_GENODE let Child = Genode.Init.Child -in { config = +in Genode.Boot::{ + , config = Genode.Init::{ , children = toMap @@ -47,17 +48,4 @@ in { config = } } } - , rom = - let manifest = env:MANIFEST - - in Genode.Boot.toRomPaths - [ manifest.bash-minimal.tar.bash-minimal - , manifest.noux.lib.libc - , manifest.noux.lib.libm - , manifest.ncurses.lib.ncurses - , manifest.noux.bin.noux - , manifest.noux.lib.libc_noux - , manifest.os.lib.vfs - , manifest.noux.lib.posix - ] } diff --git a/tests/noux.nix b/tests/noux.nix index aa18771..e0e8205 100644 --- a/tests/noux.nix +++ b/tests/noux.nix @@ -6,10 +6,8 @@ with pkgs; testEnv.mkTest rec { name = "noux"; testConfig = ./noux.dhall; - testInputs = (with pkgs; [ noux ]) ++ (with depot; [ - bash-minimal - ncurses - ]); + testInputs = [ (pkgs.genodeSources.make "noux") ] + ++ (with depot; [ bash-minimal ncurses ]); meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ]; testScript = "run_genode_until {SOTEST SUCCESS} 40"; } diff --git a/tests/pci.dhall b/tests/pci.dhall index 0f1de9a..16246f2 100644 --- a/tests/pci.dhall +++ b/tests/pci.dhall @@ -14,7 +14,8 @@ let ServiceRoute = Init.ServiceRoute let label = λ(_ : Text) → { local = _, route = _ } : Child.Attributes.Label -in { config = +in Genode.Boot::{ + , config = Init::{ , verbose = True , children = @@ -75,13 +76,4 @@ in { config = } } } - , rom = - let manifest = env:MANIFEST - - in Genode.Boot.toRomPaths - [ manifest.drivers.bin.acpi_drv - , manifest.drivers.bin.platform_drv - , manifest.os.bin.report_rom - , manifest.genode-tests.bin.test-pci - ] } diff --git a/tests/pci.nix b/tests/pci.nix index ed768d2..4341d0a 100644 --- a/tests/pci.nix +++ b/tests/pci.nix @@ -8,8 +8,13 @@ testEnv.mkTest { meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ]; testConfig = ./pci.dhall; - testInputs = [ pkgs.genodeTests pkgs.driversPc ]; + testInputs = map pkgs.genodeSources.make [ + "drivers/acpi" + "drivers/platform" + "server/report_rom" + "test/pci" + ]; testScript = '' - run_genode_until "--- Platform test finished ---.*\n" 60 + run_genode_until ".*--- Platform test finished ---.*\n" 60 ''; } diff --git a/tests/rtc.dhall b/tests/rtc.dhall index 21444eb..efa02ef 100644 --- a/tests/rtc.dhall +++ b/tests/rtc.dhall @@ -4,7 +4,8 @@ let Genode = env:DHALL_GENODE let Child = Genode.Init.Child -in { config = +in Genode.Boot::{ + , config = Genode.Init::{ , children = toMap @@ -27,9 +28,4 @@ in { config = } } } - , rom = - let manifest = env:MANIFEST - - in Genode.Boot.toRomPaths - [ manifest.genode-tests.bin.test-rtc, manifest.drivers.bin.rtc_drv ] } diff --git a/tests/rtc.nix b/tests/rtc.nix index 5e7fab1..5f4e1e5 100644 --- a/tests/rtc.nix +++ b/tests/rtc.nix @@ -8,6 +8,6 @@ testEnv.mkTest { meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ]; testConfig = ./rtc.dhall; - testInputs = with pkgs; [ driversPc genodeTests ]; + testInputs = map pkgs.genodeSources.make [ "drivers/rtc" "test/rtc" ]; testScript = "run_genode_until {--- RTC test finished ---} 40"; } diff --git a/tests/signal.dhall b/tests/signal.dhall index 07a06fc..b606a80 100644 --- a/tests/signal.dhall +++ b/tests/signal.dhall @@ -6,7 +6,8 @@ let Init = Genode.Init let Child = Init.Child -in { config = +in Genode.Boot::{ + , config = Init::{ , children = toMap @@ -25,8 +26,4 @@ in { config = } } } - , rom = - let manifest = env:MANIFEST - - in Genode.Boot.toRomPaths [ manifest.genode-tests.bin.test-signal ] } diff --git a/tests/signal.nix b/tests/signal.nix index fdac667..1cc4816 100644 --- a/tests/signal.nix +++ b/tests/signal.nix @@ -8,6 +8,6 @@ testEnv.mkTest rec { meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ]; testConfig = ./signal.dhall; - testInputs = [ pkgs.genodeTests ]; + testInputs = [ (pkgs.genodeSources.make "test/signal") ]; testScript = "run_genode_until {--- Signalling test finished ---} 120"; } diff --git a/tests/solo5/blk.dhall b/tests/solo5/blk.dhall index 53fd456..f6e2dbb 100644 --- a/tests/solo5/blk.dhall +++ b/tests/solo5/blk.dhall @@ -6,7 +6,8 @@ let Init = Genode.Init let Child = Init.Child -in { config = +in Genode.Boot::{ + , config = Init::{ , children = toMap @@ -36,11 +37,4 @@ in { config = } } } - , rom = - let manifest = env:MANIFEST - - in Genode.BootModules.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 deleted file mode 100644 index 24688b1..0000000 --- a/tests/solo5/boot-wrapper.dhall +++ /dev/null @@ -1,10 +0,0 @@ --- SPDX-License-Identifier: CC0-1.0 - -let Genode = env:DHALL_GENODE - -in λ(boot : Genode.Boot.Type) - → { config = boot.config - , rom = - Genode.BootModules.toRomPaths [ (env:MANIFEST).solo5.lib.solo5 ] - # boot.rom - } diff --git a/tests/solo5/default.nix b/tests/solo5/default.nix index d158c7e..c2b42ed 100644 --- a/tests/solo5/default.nix +++ b/tests/solo5/default.nix @@ -8,12 +8,12 @@ let run_genode_until {SUCCESS} 30 ''; - mkTest' = { name, testConfig, testScript ? defaultScript, ... }@attrs: + mkTest' = { name, testConfig, testScript ? defaultScript, testInputs ? [ ] + , ... }@attrs: testEnv.mkTest (attrs // { name = "solo5-" + name; - inherit testScript; - testInputs = [ pkgs.solo5 pkgs.solo5.tests pkgs.driversPc ]; - testConfig = "(${./boot-wrapper.dhall} ${testConfig})"; + inherit testConfig testScript; + testInputs = [ pkgs.solo5 pkgs.solo5.tests ] ++ testInputs; }); applyMkTest = x: { @@ -23,13 +23,15 @@ let mkTests = testList: builtins.listToAttrs (map applyMkTest testList); - toSimple = name: - "(${./simple.dhall} (env:MANIFEST).solo5-tests.bin.solo5-test_${name})"; + toSimple = name: ''(${./simple.dhall} \"solo5-test_${name}\")''; + + makeGenode = pkgs.genodeSources.make; tests = [ { name = "blk"; testConfig = ./blk.dhall; + testInputs = [ (makeGenode "server/ram_block") ]; } { @@ -50,11 +52,19 @@ let { name = "net"; testConfig = ./net.dhall; + testInputs = + map makeGenode [ "app/ping" "server/nic_bridge" "server/nic_loopback" ]; } { name = "net_2if"; testConfig = ./net_2if.dhall; + testInputs = map makeGenode [ + "app/ping" + "app/sequence" + "server/nic_bridge" + "server/nic_loopback" + ]; } { @@ -73,6 +83,7 @@ let ] ++ (testEnv.lib.optional (!testEnv.isLinux) { name = "time"; testConfig = ./time.dhall; + testInputs = [ (makeGenode "drivers/rtc") ]; } ); diff --git a/tests/solo5/net.dhall b/tests/solo5/net.dhall index 4b9e2ed..dc557a1 100644 --- a/tests/solo5/net.dhall +++ b/tests/solo5/net.dhall @@ -10,7 +10,8 @@ let Res = Init.Resources let ServiceRoute = Init.ServiceRoute -in { config = +in Genode.Boot::{ + , config = Init::{ , children = toMap @@ -78,13 +79,4 @@ in { config = } } } - , rom = - let manifest = env:MANIFEST - - in Genode.BootModules.toRomPaths - [ 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 1290996..b8e9c3b 100644 --- a/tests/solo5/net_2if.dhall +++ b/tests/solo5/net_2if.dhall @@ -8,7 +8,8 @@ let Child = Init.Child let Res = Init.Resources -in { config = +in Genode.Boot::{ + , config = Init::{ , children = toMap @@ -85,14 +86,4 @@ in { config = } } } - , rom = - let manifest = env:MANIFEST - - in Genode.BootModules.toRomPaths - [ 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/simple.dhall b/tests/solo5/simple.dhall index 257b7a4..4aaad5d 100644 --- a/tests/solo5/simple.dhall +++ b/tests/solo5/simple.dhall @@ -10,15 +10,16 @@ let Child = Init.Child let Config = Init.Config -in λ(testBinary : Prelude.Map.Entry Text Text) - → { config = +in λ(testBinary : Text) + → Genode.Boot::{ + , config = Init::{ , children = toMap { solo5 = Child.flat Child.Attributes::{ - , binary = testBinary.mapKey + , binary = testBinary , exitPropagate = True , resources = Init.Resources::{ @@ -39,5 +40,4 @@ in λ(testBinary : Prelude.Map.Entry Text Text) } } } - , rom = Genode.BootModules.toRomPaths [ testBinary ] } diff --git a/tests/solo5/time.dhall b/tests/solo5/time.dhall index 7a694ac..fa2b11c 100644 --- a/tests/solo5/time.dhall +++ b/tests/solo5/time.dhall @@ -4,7 +4,8 @@ let Genode = env:DHALL_GENODE let Child = Genode.Init.Child -in { config = +in Genode.Boot::{ + , config = Genode.Init::{ , children = toMap @@ -32,11 +33,4 @@ in { config = } } } - , rom = - let manifest = env:MANIFEST - - in Genode.BootModules.toRomPaths - [ manifest.solo5-tests.bin.solo5-test_time - , manifest.drivers.bin.rtc_drv - ] } diff --git a/tests/sotest-wrapper.dhall b/tests/sotest-wrapper.dhall deleted file mode 100644 index 66b8df9..0000000 --- a/tests/sotest-wrapper.dhall +++ /dev/null @@ -1,29 +0,0 @@ --- SPDX-License-Identifier: CC0-1.0 - -let Genode = env:DHALL_GENODE - -let Init = Genode.Init - -let Child = Init.Child - -let wrapSotest - : Init.Type → Child.Type - = λ(init : Init.Type) - → Child.nested - (toMap { init = Genode.Init.toChild init Init.Attributes.default }) - Child.Attributes::{ - , binary = "sotest-harness" - , 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.child "Timer" "timer" - ] - } - -in wrapSotest diff --git a/tests/test-wrapper.dhall b/tests/test-wrapper.dhall new file mode 100644 index 0000000..dc85dd3 --- /dev/null +++ b/tests/test-wrapper.dhall @@ -0,0 +1,63 @@ +-- SPDX-License-Identifier: CC0-1.0 + +let Genode = env:DHALL_GENODE + +let Prelude = Genode.Prelude + +let Init = Genode.Init + +let Child = Init.Child + +let wrapHarness + : Init.Type → Child.Type + = λ(init : Init.Type) + → Child.nested + (toMap { init = Genode.Init.toChild init Init.Attributes.default }) + Child.Attributes::{ + , binary = "sotest-harness" + , 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.child "Timer" "timer" + ] + } + +let TextMapType = Prelude.Map.Type Text + +in λ(boot : Genode.Boot.Type) + → λ(inputsManifest : TextMapType (TextMapType Text)) + → boot + ⫽ { config = + Init::{ + , children = + [ { mapKey = "timer" + , mapValue = + Child.flat + Child.Attributes::{ + , binary = "timer_drv" + , provides = [ "Timer" ] + } + } + , { mapKey = "harness", mapValue = wrapHarness boot.config } + ] + } + , rom = + let inputRoms = + Genode.BootModules.toRomPaths + ( Prelude.List.concat + (Prelude.Map.Entry Text Text) + ( Prelude.Map.values + Text + (Prelude.Map.Type Text Text) + inputsManifest + ) + ) + + in boot.rom # inputRoms + }